I'm new to PowerApps
I'm building a form which which populates a sharepoint list with some data. Among other things on my form i have 2 combo box people pickers, one for Owner which allows the selection of 1 person and one for members which allows multiple selections.
The Owners combo box has the following in the Items property
Office365Users.SearchUser({searchTerm:cb_Owner.SearchText})
While Members has the following
Office365Users.SearchUser({searchTerm:cb_members.SearchText})
I have a button which posts the data to sharepoint with the following OnSelect
Collect(
MSTSFormList,
{
Title: Label1.Text,
TeamType: DD_TeamType.Selected.'Template id',
Owner: {
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims: "i:0#.f|membership|" & Lower(cb_Owner.Selected.Mail)
},
Members: Table( {
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims: "i:0#.f|membership|" & Lower(cb_members.Selected.Mail)
}
)
}
)
Everything else works works fine however I'm struggling to get members to work. All it does is output the last person that was entered in the the members box, instead of all of them. This does make sense to me as I can see I need to put multiple entries in the table section of the collect, however I'm unsure how to go about this. I've been looking at using ForAll or possibly creating variables that I could put here but I can't figure it out.
Any help would be appreciated.
Thanks!
Solved! Go to Solution.
Hi @Anonymous :
Do you want to update multiple users to the Member field?
My method is to use the Forall function:
Please try this code:
Collect(
MSTSFormList,
{
Title: Label1.Text,
TeamType: DD_TeamType.Selected.'Template id',
Owner: {
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims: "i:0#.f|membership|" & Lower(cb_Owner.Selected.Mail)
},
Members: ForAll(
cb_members.SelectedItems,
{
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Department: "",
Claims: "i:0#.f|membership|" & Mail,
DisplayName: DisplayName,
Email: Mail,
JobTitle: "",
Picture: ""
})
}
)
Best Regards,
Bof
@Anonymous
You don't have to write all that complicated code. Just do what I have shown below.
Collect(
MSTSFormList,
{
Title: Label1.Text,
TeamType: DD_TeamType.Selected.'Template id',
Owner: cb_Owner.Selected
Members: cb_Members.SelectedItems
}
)
---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."
Hi @Anonymous :
Do you want to update multiple users to the Member field?
My method is to use the Forall function:
Please try this code:
Collect(
MSTSFormList,
{
Title: Label1.Text,
TeamType: DD_TeamType.Selected.'Template id',
Owner: {
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims: "i:0#.f|membership|" & Lower(cb_Owner.Selected.Mail)
},
Members: ForAll(
cb_members.SelectedItems,
{
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Department: "",
Claims: "i:0#.f|membership|" & Mail,
DisplayName: DisplayName,
Email: Mail,
JobTitle: "",
Picture: ""
})
}
)
Best Regards,
Bof
@v-bofeng-msft
It is not necessary to write this long block of code if the Owner and Members are found in a ComboBox.
Owner: {
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims: "i:0#.f|membership|" & Lower(cb_Owner.Selected.Mail)
},
Members: ForAll(
cb_members.SelectedItems,
{
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Department: "",
Claims: "i:0#.f|membership|" & Mail,
DisplayName: DisplayName,
Email: Mail,
JobTitle: "",
Picture: ""
})
}
As I said in my post above, the original poster can simply do this
Owner: cb_owner.Selected,
Members: cb_members.SelectedItems
@Anonymous
I suggest you do it the simple way I suggested in my 1st post.
---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."
That's done it, thank you very much!!
Knew I was on the right lines but you've just saved me several more hours of banging my head off the wall.
Thanks again
@mdevaney thanks for taking the time reply. I tried your solution but unfortunately I was getting a '!Required info' error in SharePoint.
@v-bofeng-msft solution has fixed it for me.
Thank you both
This really works
HI v-bofeng-msft,
Regarding above solution, Can you please suggest if this works for Submitform? I tried to add the code as below on Update property of the Datacard and I am getting "Expecting Record error"
ForAll(DataCardValue19.SelectedItems,
{
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims: "i:0#.f|membership|" & ThisRecord.Email,
Department: "",
DisplayName: DisplayName,
Email: Email,
JobTitle: "",
Picture: ""
)}
Can you please suggest if I am doing anyting wrong here.
BTW, My default property of the field is as I have to set logged in user as default.
If(NewRequest.Mode= FormMode.New ,{
DisplayName: User().FullName,
Claims: "i:0#.f|membership|" & User().Email
})
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
User | Count |
---|---|
257 | |
122 | |
86 | |
74 | |
71 |