Hi everyone!
I am pretty new in Power Platform and probably my question had been already asked and solved before (I checked the similarly looking ones but could not find exact one so would be glad to get any references to similar situation).
Basically I have PowerApps app where users can create/edit their posts. Admins have instant approval, the regular users will have to wait for admins to approve the post first.
I have a form to submit and to SharePoint and combobox outside of the form with which we patch the last submission. (I tried to do the combobox within the form but SP just would not get the users data and patching failed completely so I chose to divide). The post goes to PowerAutomate to approve the post if user is admin or send notification to admins. Well, the SP site and app itself were established for learning so the members have Edit permission and I added some of the names of my colleagues as members just to test if the problem was in adding non-members but that theory failed. I myself is the owner and admin.
So the combobox has user names in it (taking DisplayName from 365users) and SP has a list called Posts that has data from the form and users column that allows the multiple choices. Usually the first try (submitting the new post) goes smoothly - submission done, last submitted post gets patched, the result goes through the Power Automate. (only tested while being admin though). The problem starts with editing posts. It is held through the same page and the same button as new posts so maybe it is the issues, but the error occurs pretty randomly: 1) adding users can work on the 2nd sometimes 3rd time but in more trials causes the error that colors my Patch function red; 2) removing 1 of the users would always trigger the error (works onlyif I remove all the users though).
When error is triggered the data even does not get through the Power Automate completely (the submitted part goes but not the patch) resulting the post created by admin being Pending on SP hence needing approval.
The Save button has the following OnSelect:
SubmitForm(Form1);
Set(
userArray,
Concat(
ComboBox1.SelectedItems,
UserPrincipalName & ";"
)
);
Patch(Posts,
LookUp(Posts, ID = Form1.LastSubmit.ID),
{
AccessUsers: ForAll(
ComboBox1.SelectedItems,
{
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims: Concatenate("i:0#.f|membership|", Lower(UserPrincipalName)),
DisplayName: DisplayName,
Email: Mail,
Department: ".",
JobTitle: ".",
Picture: "."
}
)
});
createpost.Run(Form1.LastSubmit.ID, userArray); //PowerAutomate action
//Set userArray was one of my trials to do patching through actions on PowerAutomate side but even before me doing the array thing, the same Networking error would happen so I am not sure what I am doing wrong. When error is happening Power Automated gets the submition through showing that the empty (or the before-change) array of users was submitted and only saves the form's changes, not the combobox.
If anyone has an idea if I can simplify process and avoid an error or additional details are needed to detect the issue, please let me know. Thank you for your kind attention and consideration.