web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patch multiple items f...
Power Apps
Answered

Patch multiple items from gallery back to my SharePoint list

(0) ShareShare
ReportReport
Posted on by 64

Hi All,

 

I'm trying to patch multiple fields back to my SharePoint list but struggling with combining 2 working patch formulas to a single patch function.

 

Here is each patch function that works independently:

 

The below patches editable text fields in my gallery:

ForAll(Filter(OnCallPersonGallery.AllItems, OnCallToggle.Value = true),

Patch('On-Call Scheduler',

ThisRecord,

    {'Cover Start Date':DateValue('Editable Start Dates - OnCall'.Text), 'Cover End Date':DateValue('Editable End Dates - OnCall'.Text), 'Cover Start Time':'Editable Start Time - OnCall'.Text, 'Cover End Time':'Editable End Time - OnCall'.Text}));

 

The below patches a person field in my gallery:

Patch(

    'On-Call Scheduler',

    OnCallPersonGallery.Selected,

    {

        'Cover Person On Call':{

                 '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",

                  Claims:"i:0#.f|membership|" & PeoplePicker.Selected.Mail,

                  DisplayName:"",

                  Department:"",

                  Email: User().Email,

                  JobTitle:"",

                  Picture:""

               }

     }

)

 

I would like to combine them both so that they work off a single patch function and update back to my SharePoint lists with one click of a button.

 

Is anyone able to help me, please?

Categories:
  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Surfmania77 

    Your ForAll is backward, so consider the following change to your formula:

    Patch('On-Call Scheduler',
     ForAll(
     Filter(OnCallPersonGallery.AllItems, OnCallToggle.Value),
     {ID: ID, 
     'Cover Start Date': DateValue('Editable Start Dates - OnCall'.Text), 
     'Cover End Date': DateValue('Editable End Dates - OnCall'.Text), 
     'Cover Start Time': 'Editable Start Time - OnCall'.Text, 
     'Cover End Time': 'Editable End Time - OnCall'.Text,
     'Cover Person On Call':
     {
     Claims:"i:0#.f|membership|" & Lower(PeoplePicker.Selected.Mail),
     DisplayName:"",
     Department:"",
     Email: PeoplePicker.Selected.Mail,
     JobTitle:"",
     Picture:""
     }
     }
     )
    );

     

    If you based your PeoplePicker off of Choices for your list (basically a full user list) rather than the Office365 User function, then your formula would change to:

    Patch('On-Call Scheduler',
     ForAll(
     Filter(OnCallPersonGallery.AllItems, OnCallToggle.Value),
     {ID: ID, 
     'Cover Start Date': DateValue('Editable Start Dates - OnCall'.Text), 
     'Cover End Date': DateValue('Editable End Dates - OnCall'.Text), 
     'Cover Start Time': 'Editable Start Time - OnCall'.Text, 
     'Cover End Time': 'Editable End Time - OnCall'.Text,
     'Cover Person On Call':PeoplePicker.Selected,
     }
     )
    );

    Make sure your Gallery records have the record ID in them.

     

    I hope this is helpful for you.

  • Verified answer
    Surfmania77 Profile Picture
    64 on at

    I again figured it out, sorry folk but to show what I did for everyone's benefit:

     

    ForAll(Filter(OnCallPersonGallery.AllItems, OnCallToggle.Value = true),
    Patch('On-Call Scheduler',
    ThisRecord,
    {'Cover Start Date':DateValue('Editable Start Dates - OnCall'.Text), 'Cover End Date':DateValue('Editable End Dates - OnCall'.Text), 'Cover Start Time':'Editable Start Time - OnCall'.Text, 'Cover End Time':'Editable End Time - OnCall'.Text,

    'Cover Person On Call':
    {
    '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
    Claims:"i:0#.f|membership|" & OnCallPicker.Selected.Mail,
    DisplayName:"",
    Department:"",
    Email: User().Email,
    JobTitle:"",
    Picture:""
    }
    }
    ))
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Surfmania77 

    Your ForAll is still backward and your performance will suffer from it.  Also, the odata.type is no longer needed on person records. 

  • Surfmania77 Profile Picture
    64 on at

    Thanks, Randy, 

     

    That Helped 👍

  • Surfmania77 Profile Picture
    64 on at

    @RandyHayes,

     

    I now have a new issue from altering the formula, i have the people picker which is fine but have implemented a date picker to update a 'Date' Column in a SPlist and also 4 other dropdowns to populate 4 other columns (single-line text) that are Start Hour, Start Minute, End Hour, End Minute.

     

    I am now at a loss on patching this as a whole to the SPlist.

     

    As you say I no longer need to use odata for person fields which are great, can you make sense of the below?

     

    Currently looks like this, I don't want to use editable text fields anymore:

     

    Patch
    (ForAll('On-Call Scheduler',
    ThisRecord,
    {'Cover Start Date':DateValue('DatePickerStart'.SelectedDate), 'Cover End Date':DateValue('DatePickerEnd'.SelectedDate), 'Start Time Hour':'DropdownStartHour'.SelectedText.Value, 'Start Time Minute':'DropdownStartMinute'.SelectedText.Value, 'End Time Hour':'DropdownEndHour'.SelectedText.Value, 'End Time Minute':'DropdownEndMinute'.SelectedText.Value,
     
    'Cover Person On Call':
    {
    '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
    Claims:"i:0#.f|membership|" & OnCallPicker.Selected.Mail,
    DisplayName:"",
    Department:"",
    Email: User().Email,
    JobTitle:"",
    Picture:""
    }
    }
    ))
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Surfmania77 

    I am not understanding your formula as you are creating a table (from ForAll) from the OnCall Scheduler. 

    Originally your formula was based on your Gallery...which is what it should be.

    You are also using the SelectedText property of the dropdown - this should be avoided as the property is deprecated and should not be used.

     

    So your formula should be:

    Patch('On-Call Scheduler',
     ForAll(
     Filter(OnCallPersonGallery.AllItems, OnCallToggle.Value),
     {ID: ID, 
     'Cover Start Date': DatePickerStart.SelectedDate, 
     'Cover End Date': DatePickerEnd.SelectedDate, 
     'Cover Start Time Hour': DropdownStartHour.Selected.Value, 
     'Cover Start Time Minute': DropdownStartMinute.Selected.Value, 
     'Cover End Time Hour': DropdownEndHour.Selected.Value, 
     'Cover End Time Minute': DropdownEndMinute.Selected.Value, 
     'Cover Person On Call':
     {
     Claims:"i:0#.f|membership|" & Lower(PeoplePicker.Selected.Mail),
     DisplayName:"",
     Department:"",
     Email: PeoplePicker.Selected.Mail,
     JobTitle:"",
     Picture:""
     }
     }
     )
    );

    Not entirely sure the purpose of splitting the hour and minute into separate columns, but it will work as well.  Perhaps a little more streamlined though to have just a time column.  In which case you would have date and time in your start and end and the formula would be this:

    Patch('On-Call Scheduler',
     ForAll(
     Filter(OnCallPersonGallery.AllItems, OnCallToggle.Value),
     {ID: ID, 
     'Cover Start Date': 
     DatePickerStart.SelectedDate + 
     Time(DropdownStartHour.Selected.Value, DropdownStartMinute.Selected.Value, 0), 
     'Cover End Date': 
     DatePickerEnd.SelectedDate + 
     Time(DropdownEndHour.Selected.Value, DropdownEndMinute.Selected.Value, 0), 
     'Cover Person On Call':
     {
     Claims:"i:0#.f|membership|" & Lower(PeoplePicker.Selected.Mail),
     DisplayName:"",
     Department:"",
     Email: PeoplePicker.Selected.Mail,
     JobTitle:"",
     Picture:""
     }
     }
     )
    );

     

  • Surfmania77 Profile Picture
    64 on at

    Thanks, @RandyHayes,

     

    To be honest I'm not sure anymore.

     

    I don't want to use the toggle anymore, this is something I used from a Shane Young youtube video and works well in other scenarios.

     

    All i need to do now is patch:

     

    • A person Field named: OnCallPicker to SPlist Column (O365 Person Column)
    • A Date Field named: DatePickerStart to SPlist Column (Date Column)
    • A Date Field named: DatePickerEnd to SPlist Column (Date Column)
    • A Dropdown Field named: DropdownStartHour to SPlist Column (Choice Column)
    • A Dropdown Field named: DropdownStartMinute to SPlist Column (Choice Column)
    • A Dropdown Field named: DropdownEndHour to SPlist Column (Choice Column)
    • A Dropdown Field named: DropdownEndMinute to SPlist Column (Choice Column)

     

    All with a gallery, so gallery.selected

     

    Crazy setup I know but there is a method to my madness, just struggling with patching the data back to SPlist.

     

    Really appreciate your help too.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Surfmania77 

    This is the first I'm hearing about a Toggle, so not sure how that plays in.

     

    On my last response, the first formula in that should give you what you want in your bulleted list.

    I am just re-reading a bit and see that you said the hour and minute columns were text - not sure the purpose of text in this case as those would be numbers.

    But anyway, that first formula in last response would do what you need.

     

    Have you tried it?  Are there any issues you are running into?

  • Surfmania77 Profile Picture
    64 on at

    Thanks @RandyHayes,

     

    This is the toggle that i need to remove from the formula:

     

     Filter(OnCallPersonGallery.AllItems, OnCallToggle.Value),
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Surfmania77 

    Ah yes, completely breezed over that.

     

    So what is the problem with the toggle?  What is its purpose?

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 396 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 323

#3
WarrenBelz Profile Picture

WarrenBelz 193 Most Valuable Professional

Last 30 days Overall leaderboard