cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jbirkenhead
Level: Powered On

Patch multiple peoples displayname to sharepoint column from a combobox

Hi,

 

Hoping someone can help with this one as can't find the answer online anywhere. 

 

My issue is that I have a stand alone combo box within an app (not part of a gallery).

I have my items set to:

Office365Users.SearchUser({searchTerm:ComboBox1.SearchText,top:15})

And my Defaultselecteditems is set to:

First(Filter(Office365Users.SearchUser(),DisplayName = "xyz persons name"))

And my Searchfields set to:

["DisplayName"]

 

What this does is allows me to type into the combo box a persons name, and select it from a list of names within our company. I need to be able to select any amount of names here. 

 

What I need to be able to do is patch the names entered into sharepoint, initially as a new record, and I'd want to amend records too, but would just be happy to get the first bit up and running at the minute 

 

I've inserted a button in my app so that when I click on it, I want the names held within the above combo box to submit to the People2 column in my sharepoint list which is called ComplexPatchTest.

 

At the moment, I can only get this button to submit data for either the current users name, or the last name in the list of names from the combo box selection, or both, but I can't seem to get it to submit all of the names selected in the combobox. 

 

The code in my submit button is:

 

Patch(ComplexPatchTest,Defaults(ComplexPatchTest),
{ Title:"MultiPerson",
People2:
Table(
{ Claims: "i:0#.f|membership|" & ComboBox1.Selected.DisplayName,
Department:"",
DisplayName:"",
Email:"",
JobTitle:"",
Picture:""},
{ Claims: "i:0#.f|membership|" & Lower(User().Email),
Department:"",
DisplayName:"",
Email:"",
JobTitle:"",
Picture:""})
}
)

 

I don't really know what I'm doing with the Claims line of code, I'm just trying to unpick what I can find where other people have used it, and youtube videos.

 

Does anyone out there know how I can achieve what I'm trying to do here please?

 

Thanks in advance,

 

Jason.

1 ACCEPTED SOLUTION

Accepted Solutions
v-siky-msft
Level 10

Re: Patch multiple peoples displayname to sharepoint column from a combobox

Hi @jbirkenhead ,

 

Do you want to patch any amounts of people to SP list?

You can create a collection to save all selected people's required columns.

Please try this formula, put it to OnSelect of submit button.

ClearCollect(ColSelectedPeople,{Claims: "",Department:"",DisplayName:"",Email:"",JobTitle:"",Picture:""});Clear(ColSelectedPeople);
ForAll(ComboBox1.SelectedItems,Patch(ColSelectedPeople,Defaults(ColSelectedPeople),{Claims:"i:0#.f|membership|" & UserPrincipalName}));
Patch(ComplexPatchTest,Defaults(ComplexPatchTest),{ Title:"MultiPerson",People2:ColSelectedPeople})

Snipaste_2019-10-24_14-40-55.pngAnnotation 2019-10-24 143940.png

Hope this can help.

Best regards,

Sik

If this post helps, then please click on “Accept as Solution” to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-siky-msft
Level 10

Re: Patch multiple peoples displayname to sharepoint column from a combobox

Hi @jbirkenhead ,

 

Do you want to patch any amounts of people to SP list?

You can create a collection to save all selected people's required columns.

Please try this formula, put it to OnSelect of submit button.

ClearCollect(ColSelectedPeople,{Claims: "",Department:"",DisplayName:"",Email:"",JobTitle:"",Picture:""});Clear(ColSelectedPeople);
ForAll(ComboBox1.SelectedItems,Patch(ColSelectedPeople,Defaults(ColSelectedPeople),{Claims:"i:0#.f|membership|" & UserPrincipalName}));
Patch(ComplexPatchTest,Defaults(ComplexPatchTest),{ Title:"MultiPerson",People2:ColSelectedPeople})

Snipaste_2019-10-24_14-40-55.pngAnnotation 2019-10-24 143940.png

Hope this can help.

Best regards,

Sik

If this post helps, then please click on “Accept as Solution” to help the other members find it more quickly.

View solution in original post

jbirkenhead
Level: Powered On

Re: Patch multiple peoples displayname to sharepoint column from a combobox

Hi Sik,

 

Thanks very much for taking the time to look at my issue and provide a solution.

 

This does indeed work as expected. I just need to tweak the code so that I can also amend records, but I think I can do that. I'll just take some time to test it out some more before I close this issue as I may need to get back to you 🙂

 

Once again, thank you very much, this will be a massive help.

jbirkenhead
Level: Powered On

Re: Patch multiple peoples displayname to sharepoint column from a combobox

Sik,

 

I've been workign on this for a couple of hours now and need to seek some further advice.  The code you have given me works exactly how I needed it to, however I also need to be able to update records I've created. I can't seem to find the correct way to do it.

 

I've changed the initial code slightly, th eoriginal field called 'People2' is now called 'RaisedBy'. I also need to give some further information.

 

I'm working within a screen that I navigate to from another screen. When I do this I set a variable to '0' and place this number within the screen and call it 'var_crid' (this stands for variable_changerequestid), if I am creating a new issue. If I am editing an issue, the ID for that issue is brought into the screen from the sharpoint list.  The initial code you have given me is now amended to:

 

If(var_crid=0,

ClearCollect(ColSelectedPeople,{Claims:"",Department:"",DisplayName:"",Email:"",JobTitle:"",Picture:""});

Clear(ColSelectedPeople);

ForAll(comboRaisedby.SelectedItems,Patch(ColSelectedPeople,Defaults(ColSelectedPeople),{Claims:"i:0#.f|membership|"&UserPrincipalName}));

Patch(MI_Change_Requests,Defaults(MI_Change_Requests),{Title:(txt_title.Text),RaisedByPeople:ColSelectedPeople},{Issue_type:dd_Issuetype.SelectedText.DropDownValue},{Ref_product:dd_prodname.Selected.DropDownValue},{Change_summary:txt_changesummary.Text},{Estimate:txt_estimate.Text},{Status:dd_status.Selected.DropDownValue},{Priority:dd_priority.Selected.DropDownValue},{Remit:dd_remit.Selected.DropDownValue},{Dev_stream:dd_devstream.SelectedText.DropDownValue},{Product_ID:dd_prod_id.SelectedText.DropDownValue2}))

 

 

This works perfectly, but I needto be able to update records also, so I need to remove the refernce to 'Defaults', and replace it with a refernce to the 'var_crid' and the sharepoint ID, but I can't work it out. An example of what I have tried is below, but there appears to be an issue with the second instance of the 'ForAll line of code:

 

If(var_crid=0,

ClearCollect(ColSelectedPeople,{Claims:"",Department:"",DisplayName:"",Email:"",JobTitle:"",Picture:""});

Clear(ColSelectedPeople);

ForAll(comboRaisedby.SelectedItems,Patch(ColSelectedPeople,Defaults(ColSelectedPeople),{Claims:"i:0#.f|membership|"&UserPrincipalName}));

Patch(MI_Change_Requests,Defaults(MI_Change_Requests),{Title:(txt_title.Text),RaisedByPeople:ColSelectedPeople},{Issue_type:dd_Issuetype.SelectedText.DropDownValue},{Ref_product:dd_prodname.Selected.DropDownValue},{Change_summary:txt_changesummary.Text},{Estimate:txt_estimate.Text},{Status:dd_status.Selected.DropDownValue},{Priority:dd_priority.Selected.DropDownValue},{Remit:dd_remit.Selected.DropDownValue},{Dev_stream:dd_devstream.SelectedText.DropDownValue},{Product_ID:dd_prod_id.SelectedText.DropDownValue2}),


ClearCollect(ColSelectedPeople,{Claims:"",Department:"",DisplayName:"",Email:"",JobTitle:"",Picture:""});

Clear(ColSelectedPeople);

ForAll(comboRaisedby.SelectedItems,Patch(ColSelectedPeople,ID: var_crid,(ColSelectedPeople),{Claims:"i:0#.f|membership|"&UserPrincipalName}));

    Patch(MI_Change_Requests,{ID: var_crid},{Title:(txt_title.Text),RaisedByPeople:ColSelectedPeople},{Issue_type:dd_Issuetype.SelectedText.DropDownValue},{Ref_product:dd_prodname.Selected.DropDownValue},{Change_summary:txt_changesummary.Text},{Estimate:txt_estimate.Text},{Status:dd_status.Selected.DropDownValue},{Priority:dd_priority.Selected.DropDownValue},{Remit:dd_remit.Selected.DropDownValue},{Dev_stream:dd_devstream.SelectedText.DropDownValue},{Product_ID:dd_prod_id.SelectedText.DropDownValue2}))

 

Do you have any ideas please?

 

Thanks.

Helpful resources

Announcements
thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (5,153)