Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

How to Patch a Record (Person type) to a Collection

(1) ShareShare
ReportReport
Posted on by 271
I've built an app that uses a repeatable gallery to put various fields of data into a Collection, and then the user click a Submit button, and the data in the Collection is patched to a SharePoint list. It's all working well except for one field. In my gallery input data card, I have a person search combo-box for selecting a person from our Office365Users connector. The search and select function work fine... but I can't figure out how to get the Record to save to the Collection. I believe the issue might be how the Collection is being created in the first place, i.e. that specific field needs to be created in a way that accepts a record - but I've tried several approaches without success. 
 
This is the OnSelect code of the button that creates the collection:
 
ClearCollect(
    colItemsV2,
    {
        ItemNumber: varItemNumber,
        Item: "",
        RequestedFor: Blank(), //I thought this would create a "Record" type field in the collection, but ???
        RequestedForDisplay: "",
        Cost: 0,
        Quantity: 0,
        QuantityType: "Item(s)",
        DateNeeded: Today(),
        DeliveryRequired: false,
        ItemComments: "",
        Source: "",
        SourceURL: "",
        Subtotal: 0,
        ShowSaveButtons: true
    }
);
 
Navigate(scr_ComposeOrder, ScreenTransition.Fade);
 
And this is the code that saves the data to the Collection:
 
Patch(
            colItemsV2,
            ThisItem,
            {
                Item: inp_Itemv2.Text,
                RequestedFor: "" , //Not sure what to do here. The input field is a combo-box search for a person in our Office365User connection.
                Cost: Value(inp_Costv2.Text),
                Quantity: Value(inp_Quantityv2.Text),
                QuantityType: inp_QuantityTypev2.Selected.Value,
                DateNeeded: dp_DateNeededv2.SelectedDate,
                DeliveryRequired: ckbx_DeliveryReqv2.Value,
                ItemComments: inp_ItemComments.Text,
                Source: inp_Sourcev2.Text,
                SourceURL: inp_SourceURLv2.Text,
                Subtotal: Value(inp_Costv2.Text) * Value(inp_Quantityv2.Text),
                ShowSaveButtons: false
            }
        );
 
I've tried using "RequestedFor: cb_UserSearch;" and that does appear to add the record to the collection. But then when I try to Patch the collection to the SharePoint list, that's where I get stuck. I cannot figure out what needs to go after RequestedFor in the Patch to the SP List. Here's the code I have, with ???? being the confounding part...
 
ForAll(
    colItemsV2,
    If(!IsBlank(Item),
    Patch(
        'Procurement Request Line Items',
        Defaults('Procurement Request Line Items'),
        {
            Title: Item,
            RequestedFor: {
                '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                Claims: "i:0#.f|membership|" & ????,
                Department: "",
                DisplayName: "",
                Email: "",
                JobTitle: "",
                Picture: ""
                },
            Cost: Cost,
  • Verified answer
    MarcusD1 Profile Picture
    271 on at
    How to Patch a Record (Person type) to a Collection
    Turns out the goofy solution I thought was working was actually the solution. So I wanted to come back and provide the actual solution.
     
    When I navigate to the relevant screen, I start by establishing the collection in the OnSelect property of the navigation button:
     
    ClearCollect(
        colItemsV2,
        {
            ItemNumber: varItemNumber,
            //varItemNumber is a contextual variable to support a "Item #" type display in the Order Compose gallery as well as the Order confirmation screen
            Item: "",
            //This establishes this field as a "Record" type
            RequestedFor: {
                Claims: "",
                Department: "",
                DisplayName: "",
                Email: "",
                JobTitle: "",
                Picture: ""
            },...
     
    This is the OnSelect property of the button that patches a specific gallery item to the collection:
     
    Patch(
            colItemsV2,
            ThisItem,
               {
               Item: inp_Itemv2.Text,
               RequestedFor: {
                  Claims: "i:0#.f|membership|" & cb_UserSearch.Selected.Mail,
                  Department: cb_UserSearch.Selected.Department,
                  DisplayName: cb_UserSearch.Selected.DisplayName,
                  Email: cb_UserSearch.Selected.Mail,
                  JobTitle: "",
                  Picture: ""
                        },...
     
    And finally, this is the OnSuccess property of the Form I'm using to submit form data to one SP List, and collection data to a separate SP List:
     
    ForAll(
        colItemsV2,
        If(
            !IsBlank(Item),
            Patch(
                'Procurement Request Line Items',
                {
                    Title: Item,
                    'Requested For': {
                        Claims: "i:0#.f|membership|" & RequestorEmail, //RequestorEmail is established when Line Item is patched to the Collection
                        Department: "",
                        DisplayName: "",
                        Email: "",
                        JobTitle: "",
                        Picture: ""
                    },...
     
    So short answer is it does indeed use the Record structure consistently throughout.
  • CU23072131-0 Profile Picture
    2 on at
    How to Patch a Record (Person type) to a Collection
    I finally got it to work... but the solution is a bit frustrating. Turns out PA wanted the value of RequestedFor for patching the collection as simply the output of the combobox Selected value; but when patching the SharePoint list, it wanted the record values using the Claims structure. As such:
     
    //OnSelect property of the Save icon used to patch the collection
     
    Patch(
       colItemsV2,
       ThisItem,
           {
            Item: inp_Itemv2.Text,
            RequestedFor: cb_UserSearch,
            UserPrincipalName: cb_UserSearch.Selected.UserPrincipalName,
            Cost: Value(inp_Costv2.Text),...



    //OnSuccess property of the Form used to patch to SP List
     
    ForAll(
        colItemsV2,
        If(
            !IsBlank(Item),
            Patch(
                'Procurement Request Line Items',
                {
                    Title: Item,
                    RequestedFor: {
                        Claims: "i:0#.f|membership|" & cb_UserSearch.Selected.Mail,
                        Department: "",
                        DisplayName: "",
                        Email: cb_UserSearch.Selected.Mail,
                        JobTitle: "",
                        Picture: ""
                    },
                    Cost: Cost,...
     
    When I tried using the full Claims structure - it wouldn't work patching to the collection. I don't understand it - but doing it this way works. I'm discovering PA has a number of weird quirks. Like sometimes it wants .displayName, and other times it wants .DisplayName, and it simply won't work if you try to use the one it doesn't want in that particular circumstance.
  • LukasToman Profile Picture
    29 on at
    How to Patch a Record (Person type) to a Collection
     

    To patch a record of type Person from a collection to a SharePoint list, you need to handle the person field correctly in both the collection and when patching to SharePoint. The person field in SharePoint is a complex field that typically requires the Claims value of the user. When you're using a ComboBox to select a person from the Office365Users connector, you're working with a record that includes various properties of the user, but SharePoint specifically needs the Claims identifier for the person field.

    Step 1: Adjust Collection to Store User Claims

    When you add a user to the collection, ensure you're storing the necessary information to later patch to SharePoint. This often means storing the Claims value or the primary email of the user, which can be used to construct the Claims value.

    Patch(
        colItemsV2,
        ThisItem,
        {
            // Other fields...
            RequestedFor: {
                Claims: "i:0#.f|membership|" & cb_UserSearch.Selected.Email,
                DisplayName: cb_UserSearch.Selected.DisplayName
            },
            // Other fields...
        }
    );
    
    Step 2: Patching to SharePoint
    When you patch the collection to SharePoint, you need to use the Claims value you've stored in the collection. Assuming you've stored the Claims or the email in the RequestedFor field as shown above, you can reference it directly.
    
    ForAll(
        colItemsV2,
        If(
            !IsBlank(Item),
            Patch(
                'Procurement Request Line Items',
                Defaults('Procurement Request Line Items'),
                {
                    Title: Item,
                    RequestedFor: {
                        '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                        Claims: RequestedFor.Claims
                    },
                    // Other fields...
                }
            )
        )
    );
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    Patch(
        colItemsV2,
        ThisItem,
        {
            // Other fields...
            RequestedFor: {
                Claims: "i:0#.f|membership|" & cb_UserSearch.Selected.Email,
                DisplayName: cb_UserSearch.Selected.DisplayName
            },
            // Other fields...
        }
    );
     
  • Michael E. Gernaey Profile Picture
    41,385 Super User 2025 Season 1 on at
    How to Patch a Record (Person type) to a Collection
    Hi
     
    oh so you have two things... one was what to initialize it with and one is to put it. So make sure when you add to your collection that you add their claims too. Otherwise it wont work.
     
    ForAll(
        colItemsV2,
        If(!IsBlank(Item),
        Patch(
            'Procurement Request Line Items',
            Defaults('Procurement Request Line Items'),
            {
                Title: Item,
                RequestedFor: {
                    '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                    Claims: "i:0#.f|membership|" & Lower(YourDropDownOrComboPerson.Selected.Claims),
                    Department: "",
                    DisplayName: "",
                    Email: "",
                    JobTitle: "",
                    Picture: ""
                    },
                Cost: Cost,
     
    Or you can just do this
    Claims: "i:0#.f|membership|Lower(theiremailaddress)"

  • Michael E. Gernaey Profile Picture
    41,385 Super User 2025 Season 1 on at
    How to Patch a Record (Person type) to a Collection
    Hi,
     
    try using { } with no space
    if its more than one use [] no spaces
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,702 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,015 Most Valuable Professional

Leaderboard