Blog
Forms - How to show Office 365 user profile details on a form
For business apps that are designed to facilitate collaboration, there may be the need to display the details of the currently logged on user, or some other specific user. This post walks through how to display user details on a canvas app form.
Unfortunately, the ability to carry out this task Is more difficult than it could be, compared to other platforms or systems. To give an example, a Portal App contains a built-in page that displays and enables the user to edit their profile details. This feature is entirely built-in, and there are no additional to carry out.
Displaying details of the current user in a form control
To display the Microsoft/Office 365 profile of the details of the logged in user, the first step is to add the "Office 365 Users" data source to an app.
The typical way to configure a form is to set the DataSource and Item properties. To display the current user, we can set both of these properties to the following formula:
Office365Users.MyProfile()
ThisItem.City
ThisItem.CompanyName
ThisItem.Country
ThisItem.Department
ThisItem.DisplayName
ThisItem.GivenName
ThisItem.Id
ThisItem.JobTitle
ThisItem.Mail
ThisItem.MailNickname
ThisItem.mobilePhone
ThisItem.OfficeLocation
ThisItem.PostalCode
ThisItem.Surname
ThisItem.TelephoneNumber
ThisItem.UserPrincipalName
ThisItem.AccountEnabled
Displaying details of a specific user in a form (by email address)
To display the details of a specific user, we set the DataSource
and Item properties the result of the UserProfileV2 method. We pass the target address of the user to this method.
Office365Users.UserProfileV2("targetUser@domain.com")
aboutMe, accountEnabled, birthday, businessPhones, city, companyName, country,
department, displayName, givenName, hireDate, id, interests, jobTitle, mail,
mailNickname, mobilePhone, mySite, officeLocation, pastProjects, postalCode,
preferredLanguage, preferredName, responsibilities, schools, skills, state,
streetAddress, surname, userPrincipalName, userType
Conclusion
- Categories:
- forms
- Forms - How to set the value of a field to todays date for new records only
- Apps - How to create an app from a hand drawn image
- Forms - How to highlight user modified field values on a form
- Forms - How to append text to field in a data source
- Forms - How to calculate values (eg sums and products) and store the results in SharePoint or other datasource
- SharePoint - How to programmatically set and clear single select choice items in a combo box on a form
- SharePoint - How to clear datetime fields/set an empty datetime value on a form
- Forms - How to convert a display form to an edit form
- Forms - How to copy/save an existing record on a form as a new record
- Forms - How to hide fields that are blank, or have not been completed
- Forms - How to select-all / unselect-all checkbox or toggle controls on a form
- Forms - How to set the data source of a form to a collection
- Forms - The best practice for setting the data item on a form
- Controls - How to set default control and form values
- Forms - How to conditionally make form fields mandatory