cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PaperGirl
Frequent Visitor

Patch a SharePoint list based on a combo box and collection (multi-patch)

Hi Community! 

 

I'm hoping someone can help a noob.  I have a gallery with a list of courses.  I created a Select all toggle (outside the gallery) that is programmed to select all the courses within a filtered category, the toggle inside the gallery is set to patch to a collection and update an added column (is chosen).  

Toggle OnCheck

 

Patch(colAssign,ThisItem,{IsChosen:true});

 

The idea behind this is that I want to be able to assign multiple courses to a user or users. I have a separate window that opens with a mutli-select combobox for the user selection and an assign button. 

 

Currently the assign button will patch a share point training log and add the user in the AssignedTo field.  My question is how do I patch all the selected records in my collection where the IsChosen column is true? 

 

ForAll(
    ComboBox1_3.SelectedItems,
    Patch(
        'Training Log',
        Defaults('Training Log'),
        {
            Title: selectedCourse.Title,
            TrainingID: selectedCourse.ID,
            AssignedToEmail: ThisRecord.Mail,
            AssignedTo: {
                '@odata': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                ODataType: Blank(),
                Claims: "i:0#.f|membership|" & ThisRecord.Mail,
                Department: "",
                DisplayName: ThisRecord.DisplayName,
                Email: ThisRecord.Mail,
                JobTitle: "",
                Picture: ""
            },
            DueDate: DatePicker1_3.SelectedDate,
            Status: "Pending"
        }
    );
    
);
Reset(DatePicker1_3);
Reset(ComboBox1_3);
UpdateContext({showAssign: false});
Refresh('Training Log');

I've tried numerous searches and combinations, but I'm stuck at how to make it patch for both Combo box and the collection. 

 

Thank you, 

1 REPLY 1
WarrenBelz
Super User
Super User

Hi @PaperGirl ,

The Collection patch would be this pattern - I have simply used the same fields as an example.

Patch(
   'Training Log',
   ForAll(
      Filter(
         YourGalleryName.AllItems,
         IsChosen
      ) As aPatch,
      {
         Title: aPatch.Title,
         TrainingID: aPatch.ID
         AssignedToEmail: aPatch.Mail,
         AssignedTo: 
         {
            '@odata': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
            ODataType: Blank(),
            Claims: "i:0#.f|membership|" & aPatch.Mail,
            Department: "",
            DisplayName: aPatch.DisplayName,
            Email: aPatch.Mail,
            JobTitle: "",
            Picture: ""
         },
         DueDate: DatePicker1_3.SelectedDate,
         Status: "Pending"
      }
   )
);

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,758)