jmciver
jmciver

Reputation: 33

How to get the correct record schema for sending a user through a Patch function in Powerapps

I am trying to use the Patch function in powerapps to send a user to a Sharepoint list.

I have tried to do something along the lines of including this in my Patch:

{  
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",  
DisplayName:User().FullName,
Email:User().Email
}

So for example I'll have

    Patch('Issue Tracker', Defaults('Issue Tracker'),{
        'Project Name':ProjectName,'Occurred at Timestamp': DateTimeValue(DateTimeString)- (14/24), 'Reported By':     {  
        '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",  
        DisplayName:User().FullName,
        Email:User().Email
        }
}

The error I get from this is that I am missing a column from my User record, I need a column called "Claim", and it is of type Text.

I can't find any reference to Claim in the intellisense of the User() function, nor can I find any reference to Claim in the Office365Users.MyProfile() function, so I can't just say "User().Claim" for this field (for example).

So if I add the claim column by just saying 'Claim: ""', and carrying on, I get an error for a missing column called "JobTitle" etc.

So that eventually my record looks like this:

{  
    '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",  
    DisplayName:User().FullName,
    Email:User().Email,
    Claims: "",
    Department: Office365Users.MyProfile().Department,
    JobTitle:Office365Users.MyProfile().JobTitle,
    Picture:User().Image
    }

After this, the error I get is that the user wasn't found.

I don't know what to put for Claims, I don't know how to get the correct information. I want to keep a log of the person who reported the issue, without needing the person to manually select themselves from a combobox or dropdown list.

Can anybody help?

Upvotes: 1

Views: 2563

Answers (1)

carlosfigueira
carlosfigueira

Reputation: 87293

The 'Claims' property of a Person record in SharePoint does not have a very user-friendly format. It should be something along the lines of

"i:0#.f|membership|" & User().Email

To know for sure what the expected value / format in your SharePoint list, you can add a label to your app that lists the property of one of the users:

First('Issue Tracker').'Reported By'.Claims

You can find more information on the blog post at https://powerapps.microsoft.com/blog/default-values-for-complex-sharepoint-types/ about sending Person objects to SharePoint.

Upvotes: 1

Related Questions