Introduction
User profile properties provide information about SharePoint users, such as display name, email, account name and other business and personal information including custom properties.
User profile properties provide information about SharePoint users, such as display name, email, account name and other business and personal information including custom properties.
Imagine
Imagine I want to retrieve a custom field from the user profile property with REST. The property is searchable in a search box. The name of the custom properties are "Employee ID" and "Division”.
But when I try to use http://siteurl/_api/SP.UserProfiles.PeopleManager/GetMyProperties, it does not retrieve the custom properties, on the contrary I can see only the built-in properties like:
Let's proceed
I've created a UserProfile with some custom properties.
When I use http://siteurl/_api/SP.UserProfiles.PeopleManager/GetMyProperties, I get a result set with all UserProfile properties, including my custom properties. Right now I am using a workaround that iterates through the (big) result set with all properties to get my custom property.
Step 1: Navigate to your SharePoint 2013 site.
Step 2: From this page select the Site Actions | Edit Page.
Edit the page, go to the "Insert" tab in the Ribbon and click the "Web Part" option. In the "Web Parts"dialogue, go to the "Media and Content" category, select the "Script Editor" Web Part and click the "Add button".
Step 3: Once the Web Part is inserted into the page, you will see an "EDIT SNIPPET" link; click it. You can insert the HTML and/or JavaScript as in the following:
SPS: ResourceSID
SPS: AltCalendarType
SPS: Responsibility
SPS: Birthday
SPS: SavedAccountName
SPS: CalendarType
SPS: SavedSID
SPS: ClaimID
SPS: School
SPS: ClaimProviderID
SPS: ShowWeeks
SPS: ClaimProviderType
SPS:SipAddress
SPS:ContentLanguages
SPS:Skills
SPS:DataSource
SPS:SourceObjectDN
SPS:Department
SPS:StatusNotes
SPS:DisplayOrder
SPS:Time24
SPS:DistinguishedName
SPS:TimeZone
SPS:DontSuggestList
SPS: UserPrincipalName
SPS:Dotted:line
SPS:WorkDayEndHour
SPS:EmailOptin
SPS:WorkDayStartHour
SPS:FeedIdentifier
SPS:WorkDays
SPS:FirstDayOfWeek
Title
SPS:FirstWeekOfYear
UserName
SPS:HashTags
UserProfile_GUID
SPS:HireDate
WebSite
SPS:Interests
WorkEmail
SPS:JobTitle
WorkPhone
SPS:LastColleagueAdded
Imagine I want to retrieve a custom field from the user profile property with REST. The property is searchable in a search box. The name of the custom properties are "Employee ID" and "Division”.
But when I try to use http://siteurl/_api/SP.UserProfiles.PeopleManager/GetMyProperties, it does not retrieve the custom properties, on the contrary I can see only the built-in properties like:
- AccountName
- DisplayName
Let's proceed
I've created a UserProfile with some custom properties.
When I use http://siteurl/_api/SP.UserProfiles.PeopleManager/GetMyProperties, I get a result set with all UserProfile properties, including my custom properties. Right now I am using a workaround that iterates through the (big) result set with all properties to get my custom property.
Step 1: Navigate to your SharePoint 2013 site.
Step 2: From this page select the Site Actions | Edit Page.
Edit the page, go to the "Insert" tab in the Ribbon and click the "Web Part" option. In the "Web Parts"dialogue, go to the "Media and Content" category, select the "Script Editor" Web Part and click the "Add button".
Step 3: Once the Web Part is inserted into the page, you will see an "EDIT SNIPPET" link; click it. You can insert the HTML and/or JavaScript as in the following:
- <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery:1.10.1.min.js"></script>
- <script type='text/javascript'>
- var workEmail = "";
- var EmployeeID = "";
- var Division = "";
- var userDisplayName = "";
- var AccountName = "";
- $.ajax({
- url: _spPageContextInfo.webAbsoluteUrl + "/_api/SP.UserProfiles.PeopleManager/GetMyProperties",
- headers: { Accept: "application/json;odata=verbose" },
- success: function (data) {
- try {
- //Get properties from user profile Json response
- userDisplayName = data.d.DisplayName;
- AccountName = data.d.AccountName;
- var properties = data.d.UserProfileProperties.results;
- for (var i = 0; i < properties.length; i++) {
- var property = properties[i];
- if (property.Key == "WorkEmail") {
- workEmail = property.Value;
- }
- if (property.Key == "EmployeeID") {
- EmployeeID = property.Value;
- }
- if (property.Key == "Division") {
- Division = property.Value;
- }
- }
- $('#AccountName').text(AccountName);
- $('#userDisplayName').text(userDisplayName);
- $('#EmployeeID').text(EmployeeID);
- $('#workEmail').text(workEmail);
- $('#Division').text(Division);
- } catch (err2) {
- //alert(JSON.stringify(err2));
- }
- },
- error: function (jQxhr, errorCode, errorThrown) {
- alert(errorThrown);
- }
- });
- </script>
- <h2><strong>Employee Details</strong></h2>
- <br />
- AccountName <span id="AccountName"></span>
- DisplayName <span id="userDisplayName"></span>
- EmployeeID <span id="EmployeeID"></span>
- Email Address <span id="workEmail"></span>
- Division <span id="Division"></span>
User Properties
The following is the list of User Properties (use the GetPropertiesFor function for these):
AccountName
DirectReports
DisplayName
Email
ExtendedManagers
ExtendedReports
IsFollowed
LatestPost
Peers
PersonalUrl
PictureUrl
Title
UserProfileProperties
UserUrl
User Profile Properties
AccountName
DirectReports
DisplayName
ExtendedManagers
ExtendedReports
IsFollowed
LatestPost
Peers
PersonalUrl
PictureUrl
Title
UserProfileProperties
UserUrl
User Profile Properties
The following is the list of User Profile Properties:
AboutMe
SPS: LastKeywordAdded
AccountName
SPS: Locale
ADGuid
SPS: Location
Assistant
SPS: MasterAccountName
CellPhone
SPS: MemberOf
Department
SPS: MUILanguages
EduExternalSyncState
SPS: MySiteUpgrade
EduOAuthTokenProviders
SPS: O15FirstRunExperience
EduPersonalSiteState
SPS: ObjectExists
EduUserRole
SPS: OWAUrl
Fax
SPS: PastProjects
FirstName
SPS: Peers
HomePhone
SPS: PersonalSiteCapabilities
LastName
SPS: PersonalSiteInstantiationState
Manager
SPS: PhoneticDisplayName
Office
SPS: PhoneticFirstName
PersonalSpace
SPS: PhoneticLastName
PictureURL
SPS: PrivacyActivity
PreferredName
SPS: PrivacyPeople
PublicSiteRedirect
SPS: ProxyAddresses
QuickLinks
SPS: RegionalSettings:FollowWeb
SID
SPS: RegionalSettings:Initialized
SISUserId
SPS: ResourceAccountName
SPS: AdjustHijriDays
AboutMe
SPS: LastKeywordAdded
AccountName
SPS: Locale
ADGuid
SPS: Location
Assistant
SPS: MasterAccountName
CellPhone
SPS: MemberOf
Department
SPS: MUILanguages
EduExternalSyncState
SPS: MySiteUpgrade
EduOAuthTokenProviders
SPS: O15FirstRunExperience
EduPersonalSiteState
SPS: ObjectExists
EduUserRole
SPS: OWAUrl
Fax
SPS: PastProjects
FirstName
SPS: Peers
HomePhone
SPS: PersonalSiteCapabilities
LastName
SPS: PersonalSiteInstantiationState
Manager
SPS: PhoneticDisplayName
Office
SPS: PhoneticFirstName
PersonalSpace
SPS: PhoneticLastName
PictureURL
SPS: PrivacyActivity
PreferredName
SPS: PrivacyPeople
PublicSiteRedirect
SPS: ProxyAddresses
QuickLinks
SPS: RegionalSettings:FollowWeb
SID
SPS: RegionalSettings:Initialized
SISUserId
SPS: ResourceAccountName
SPS: AdjustHijriDays
SPS: ResourceSID
SPS: AltCalendarType
SPS: Responsibility
SPS: Birthday
SPS: SavedAccountName
SPS: CalendarType
SPS: SavedSID
SPS: ClaimID
SPS: School
SPS: ClaimProviderID
SPS: ShowWeeks
SPS: ClaimProviderType
SPS:SipAddress
SPS:ContentLanguages
SPS:Skills
SPS:DataSource
SPS:SourceObjectDN
SPS:Department
SPS:StatusNotes
SPS:DisplayOrder
SPS:Time24
SPS:DistinguishedName
SPS:TimeZone
SPS:DontSuggestList
SPS: UserPrincipalName
SPS:Dotted:line
SPS:WorkDayEndHour
SPS:EmailOptin
SPS:WorkDayStartHour
SPS:FeedIdentifier
SPS:WorkDays
SPS:FirstDayOfWeek
Title
SPS:FirstWeekOfYear
UserName
SPS:HashTags
UserProfile_GUID
SPS:HireDate
WebSite
SPS:Interests
WorkEmail
SPS:JobTitle
WorkPhone
SPS:LastColleagueAdded
No comments:
Post a Comment