cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Writing multiple people from people picker back to SharePoint

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!

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

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: ""
            })
  }
)

 

 62.gif

Best Regards,

Bof

View solution in original post

8 REPLIES 8
mdevaney
Super User
Super User

@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."

v-bofeng-msft
Community Support
Community Support

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: ""
            })
  }
)

 

 62.gif

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."

Anonymous
Not applicable

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

Anonymous
Not applicable

@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

Hi, how are you patching this? From your gif file seems like upon running the code above it writes to the SharePoint list/library but I suspect that is not the case. Appreciate your response.

This really works

 

HI ,


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
})

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (3,039)