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:
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:
Thanks for the help!
Solved! Go to Solution.
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:
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.
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
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:
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 😄
User | Count |
---|---|
159 | |
86 | |
68 | |
63 | |
62 |
User | Count |
---|---|
210 | |
151 | |
93 | |
81 | |
69 |