Hello everyone,
I'm working on a PowerApps form connected to a SharePoint list. This list contains several different fields; single line of text, date and time, and person/group. One of the requirements is to retrieve the current user's manager and automatically populate the Person field in PowerApps. As everybody else has mentioned, a SharePoint Person/Group field becomes a dropdown in PowerApps and it's difficult to set a default value to it. For example, I can retrieve the current user's manager and pass its value to a label or text field, but can't pass it to this dropdown. Whenever I try to set the value using the formula:
Office365Users.Manager(Office365Users.MyProfile().Mail).DisplayName, I get the message "The property expects Record values, but this rule produces incompatible Text values".
Has anybody had any luck achieving this? Thanks in advanced.
Solved! Go to Solution.
I had setup SharePoint Person/Group field which automatically defaults to user manager.
To achieve this you have to add Office 365 Users connector.
In the OnVisible property of the Screen where the Form is located I have the following function:
UpdateContext( { Manager:Office365Users.Manager(First(UserProfileCollection).Id) } )
Basically this LooksUp the manager of the person.
UserProgileCollection is a collection which is setup on the start of the app this way:
Collect(UserProfileCollection,Office365Users.MyProfile()))
Basically, it just collects all info available from the Office 365 Users connector on the User.
Then in your form for the Person/Group card add the following formula for the Default property:
{ '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser", Claims:Concatenate("i:0#.f|membership|",Manager.Mail), Department:Manager.Department, DisplayName:Manager.DisplayName, Email:Manager.Mail, JobTitle:Manager.JobTitle, Picture:"" }
You can do all the calling in the Default function but it will slow down your app, as well as, you can do it for any user in your organization if you know their email.
Hi @faustocapellanj,
Sorry but the Office365Users.MyProfile().Mail and Office365Users.UserProfile( ).DisplayName are both for Office 365 Users connector, not for SharePoint Person/Group column. Office 365 users connector gets user accounts from the Azure AD not SharePoint. This is why the formula won't work as expected. Please try to add the office 365 data source in this app and then test.
Regards,
Mona
I had setup SharePoint Person/Group field which automatically defaults to user manager.
To achieve this you have to add Office 365 Users connector.
In the OnVisible property of the Screen where the Form is located I have the following function:
UpdateContext( { Manager:Office365Users.Manager(First(UserProfileCollection).Id) } )
Basically this LooksUp the manager of the person.
UserProgileCollection is a collection which is setup on the start of the app this way:
Collect(UserProfileCollection,Office365Users.MyProfile()))
Basically, it just collects all info available from the Office 365 Users connector on the User.
Then in your form for the Person/Group card add the following formula for the Default property:
{ '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser", Claims:Concatenate("i:0#.f|membership|",Manager.Mail), Department:Manager.Department, DisplayName:Manager.DisplayName, Email:Manager.Mail, JobTitle:Manager.JobTitle, Picture:"" }
You can do all the calling in the Default function but it will slow down your app, as well as, you can do it for any user in your organization if you know their email.
Hi @v-monli-msft,
While I thank you for taking the time to reply to my issue, I am aware that I need to use the Office 365 Users connector and I am currently using it in my application. My issue is not retrieving information about the current user, but with setting a default value to a Person field dropdown in PowerApps. Another user, @Anonymous, suggested an approach to achieving what I'm trying to do, but I'm not able to set such default value.
Thanks.
Hi @Anonymous,
I had posted something before about your suggestions not working, but I just checked my app and the field is populated with the current user manager. Thank you so much.
User | Count |
---|---|
252 | |
107 | |
88 | |
51 | |
44 |