0

I have a Microsoft Power App that I'm currently developing for my company to keep track of contacts for different projects. One thing that's crucial to this is being able to input new contacts to the dataset, as it's constantly changing and expanding.

The main issue I'm running into with this (which may be due to me only being able to access the web app, not the full desktop app) is that when I try to send the 'person' type to the List using the Patch() function as such,

Patch(
    ListName,
    Defaults(ListName),
    {
        Person: ComboBox2.Selected
    }
)

I get the following errors:

Invalid argument type. Expecting a record value, but of a different schema.
- And -
Missing column. Your formula is missing a column 'Claims' of type 'Text'.

I looked into this because surely I wasn't actually missing this 'Claims' column, as it's nowhere in any of my datasets or the app. However, I came to find out that apparently the 'person' type has a hidden Claims column in each entry. I tried adding records manually like this:

Person: {
            Claims: LookUp(Office365Users.SearchUserV2({searchTerm: ComboBox2_1.Selected.Email}), 
            Value = ComboBox2_1.Selected.Email).Claims,
            DisplayName: ComboBox2_1.Selected.DisplayName,
            Email: ComboBox2_1.Selected.Email
        }

To which I received the following error:

Incompatible type. The 'claims' column in the data source you're updating expects a 'text' type and you're using a 'error' type

Meaning I couldn't actually retrieve claim information, so it's not there for the person I'm fetching (I think). I'm assuming there are mismatched types here because I'm on the web app or something like that, but I would like to see if anyone has similar experience with this issue to say for sure. I'm thinking this may also be the reason for the first error, 'Invalid argument type,' suggesting I am giving it a record, but it needs to be formatted differently to work properly. Any help is tremendously appreciated, I've been going in a circle all day trying to get this to work.

Jeff Aubé
  • 31
  • 6

3 Answers3

0

To store value in people picker column you need people picker column object. Create one collection with your combobox value using people picker column object and pass that collection to people picker column.

ClearCollect(peoples, blank());
ForAll(combobox.selecteditems, collect(peoples, {  
                            '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",  
                            DisplayName:ThisRecord.DisplayName,
                            Claims:ThisRecord.Claims,
                            Department:ThisRecord.Department,
                            Email:ThisRecord.Email,
                            JobTitle:ThisRecord.JobTitle,
                            Picture:""
                        }))
    Patch(
        ListName,
        Defaults(ListName),
        {
            Person: peoples
       }
    )
Hardik
  • 11
  • 4
  • This logic works, but you are not solving the original question of how to get the 'Claims' field right. Office365Users returns an array of User objects, with a schema different from Sharepoint's schema. – mmikesy90 Jul 31 '23 at 11:54
  • If you not able to get the claim then just concatenate "i:0#.f|membership|" and email address. – Hardik Aug 01 '23 at 09:53
0

Your Combobox2_1 should have the Choices() function in its Items property.

In your question, you said you are collecting contacts for projects. Since you are trying to save these people in a SharePoint field of type 'Person or Group', you are assuming that all of these contacts have some kind of user account in your tenant. Otherwise, they would be external contancts that you cannot save in a person or group field, since they will not be found with the Office365Users connector. If you expect external project contacts, you should replace your person or group field altogether and save email addresses only.

With the Choices function any person you select in the combobox is already a record formatted in the exact way it is retrieved from and should be sent to SharePoint. Therefore there is absolutely no need to try to match that person data schema manually. With this setup you can rely on your formula referencing the .Selected property or event implement a multi-select scenario as proposed by Hardik in a previous answer.

mmikesy90
  • 783
  • 1
  • 4
  • 11
0

Try this:

Set items property of ComboBox control to:

Office365Users.SearchUserV2({searchTerm: Self.SearchText, top:50}).value

Then you can Patch person column in SharePoint list using formula:

Patch(
    ListName,
    Defaults(ListName),
    {
        Title: TextInput1.Text,
        Person: {
            '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
            Claims: "i:0#.f|membership|" & ComboBox2.Selected.Mail,
            Department: "",
            DisplayName: ComboBox2.Selected.DisplayName,
            Email: ComboBox2.Selected.Mail,
            JobTitle: "",
            Picture: ""
        }
    }
)
Ganesh Sanap
  • 1,386
  • 1
  • 8
  • 18