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

Patch + forall a sharepoint person column with multiple people in power apps

Hello guys,

 

Can you help me using Forall with Patch using a collection? The Person combobox selections are registered in the collection. I need to register each person record and each selected group in the Group combobox.

 

I need the records like this in Sharepoint:

register.PNG

 

 

 

 

 

 

 

 

My colPeopleToPatch collection used in the Patch:

 

Clear(colPeopleToPatch);;
ForAll(
    DataCardValue16.SelectedItems; //combobox person
    Collect(
        colPeopleToPatch;
        {
            '@odata.type': "#Microsoft.Azure.Connectors.Sharepoint.SPListExpandedUser";
            Claims: "i:0#.f|membership|" & ThisRecord.Email;
            Department: "";
            DisplayName: ThisRecord.DisplayName;
            Email: ThisRecord.Email;
            JobTitle: "";
            Picture: ""
        
        }
    )
);;

 

 

My Patch when I submit the form:

 

ForAll(colPeopleToPatch; //for each person in the colection
    ForAll(ComboBox1_2.SelectedItems; //for each group selected
        Patch(GPE_testes; Defaults(GPE_testes);
            {
                Grupo: Value; //comobobox group
                //register each person in the collection
                Pessoa: Table(
                    {
                        '@odata.type': "#Microsoft.Azure.Connectors.Sharepoint.SPListExpandedUser";
                        Claims: "i:0#.f|membership|" & ThisRecord.Email;
                        Department: "";
                        DisplayName: ThisRecord.DisplayName;
                        Email: ThisRecord.Email;
                        JobTitle: "";
                        Picture: ""
                    }
                );
                Navio: Concat(ComboBox1_3.SelectedItems; Value; ", ")
            }
        )
    )
);;
ClearCollect(colPeopleToPatch; Blank());;

 

 

My form:

form.PNG

 

 

 

 

 

 

 

 

Thanks for the help!

1 ACCEPTED SOLUTION

Accepted Solutions
schaungustavo
Frequent Visitor

After a lot of insistence, I managed to solve it.

I inverted the two Foralls and aliased the combobox output using As.

 

It was like this:

ForAll(ComboBox1_2.SelectedItems As Grupo,
ForAll(colPeopleToPatch, //for each person in the colection
        Patch(GPE_testes, Defaults(GPE_testes),
            {
                Grupo: Grupo.Value, //comobobox group
                //register each person in the collection
                Pessoa: Table(
                    {
                        '@odata.type': ThisRecord.'@odata.type',
                        Claims: ThisRecord.Claims,
                        Department: ThisRecord.Department,
                        DisplayName: ThisRecord.DisplayName,
                        Email: ThisRecord.Email,
                        JobTitle: ThisRecord.JobTitle,
                        Picture: ThisRecord.Picture
                    }
                ),
                Navio: Concat(ComboBox1_3.SelectedItems, Value, ", ")
            }
        )
)
);
ClearCollect(colPeopleToPatch, Blank());

 

The sharepoint registration was as I wanted:

Screenshot 2022-06-24 194507.jpg

View solution in original post

5 REPLIES 5
EddieE
Solution Sage
Solution Sage

@schaungustavo 

Try this

 

 

Patch(GPE_testes; Defaults(GPE_testes);
UnGroup(
    AddColumns(    
    ComboBox1_2.SelectedItems; 
    "People"; 
    DataCardValue16.SelectedItems
    );
    "People"
)
)
    

 

 

I think this will work, sorry cannot test to check at the moment

@EddieE , I didn't understand.

 

Where do I use it?

My problem is in the Patch of Person, linked to the first ForAll using my colection which contains records of each person selected in the combobox.

 

Screenshot 2022-06-24 185859.jpg

 

 

 

@schaungustavo 

My apologies, I should’ve mentioned that my code replace ALL of your code ie the first ClearCollect to collect people to patch as well as your ForAll + Patch code

schaungustavo
Frequent Visitor

After a lot of insistence, I managed to solve it.

I inverted the two Foralls and aliased the combobox output using As.

 

It was like this:

ForAll(ComboBox1_2.SelectedItems As Grupo,
ForAll(colPeopleToPatch, //for each person in the colection
        Patch(GPE_testes, Defaults(GPE_testes),
            {
                Grupo: Grupo.Value, //comobobox group
                //register each person in the collection
                Pessoa: Table(
                    {
                        '@odata.type': ThisRecord.'@odata.type',
                        Claims: ThisRecord.Claims,
                        Department: ThisRecord.Department,
                        DisplayName: ThisRecord.DisplayName,
                        Email: ThisRecord.Email,
                        JobTitle: ThisRecord.JobTitle,
                        Picture: ThisRecord.Picture
                    }
                ),
                Navio: Concat(ComboBox1_3.SelectedItems, Value, ", ")
            }
        )
)
);
ClearCollect(colPeopleToPatch, Blank());

 

The sharepoint registration was as I wanted:

Screenshot 2022-06-24 194507.jpg

@schaungustavo 

Im curious, did you try my code and did it work?

 

The UnGroup( AddColumns()) structure produces a Cartesian Product similar to that of ForAll( ForAll()). I’ve tested this on collections and it works but I’ve yet to test it on Complex column types like Person and Choice fields. 

I was wondering if it works for those field types as well 😄

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (1,604)