I have a listbox that a user can select mutiple values. I need to be able to save those values separately in my sharepoint list. I have about 10 different items in the listbox and want to save each item into a different field/column. This basically will allow me to see how many people pick each certain item when analying the data.
Solved! Go to Solution.
Hi @alex5p ,
What is the type of columns that save each items? What is the items property of listbox?
The final formulas is up to the column type of SP list. However i have made a test, you can refer to my example(just 4 items).
1. create 4 single-text columns for SP list, named T1, T2, T3, T4.
2. set the items property of list box as below, the 4 list items are "A","B","C","D", and append to ID for each items for convenience of lookup.
Table({Value:"A",ID:1},{Value:"B",ID:2},{Value:"C",ID:3},{Value:"D",ID:4})
3. set the following formula to button OnSelect, each column corresponds to each item. e.g. T1 column corresponds to the value that ID=1.
ClearCollect(col,ListBox1.SelectedItems);Patch('SP list',Defaults('SP list'),{Title:"Test-1",T1:LookUp(col,ID=1,Value),T2:LookUp(col,ID=2,Value),T3:LookUp(col,ID=3,Value),T4:LookUp(col,ID=4,Value)})
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.
Hi @alex5p ,
What is the type of columns that save each items? What is the items property of listbox?
The final formulas is up to the column type of SP list. However i have made a test, you can refer to my example(just 4 items).
1. create 4 single-text columns for SP list, named T1, T2, T3, T4.
2. set the items property of list box as below, the 4 list items are "A","B","C","D", and append to ID for each items for convenience of lookup.
Table({Value:"A",ID:1},{Value:"B",ID:2},{Value:"C",ID:3},{Value:"D",ID:4})
3. set the following formula to button OnSelect, each column corresponds to each item. e.g. T1 column corresponds to the value that ID=1.
ClearCollect(col,ListBox1.SelectedItems);Patch('SP list',Defaults('SP list'),{Title:"Test-1",T1:LookUp(col,ID=1,Value),T2:LookUp(col,ID=2,Value),T3:LookUp(col,ID=3,Value),T4:LookUp(col,ID=4,Value)})
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.
@v-siky-msft This works perfect thank you! I just thought of this. I have a edit screen built into my app and i want to allow the user to make an edit to the column. For instance I have 1 column named Newspaper. I changed the code a little bit from what you have and have a yes import into the column instead of grabbing the value. So when someone picks Newspaper it's column should say yes. I wanted to make the column as a choice column so when the user goes back to edit they only have an option to either select yes or no. I get an error saying expected record and found type text which is expected.
I know I can get this to work with just using dropdowns but I would have like 10 dropdowns which would be too overwhelming/ugly so that kinda why I am trying to go the route of using a listbox.
Hi @alex5p ,
Do you mean that you hardcode the "Yes" in you patch formula, and when users select the newspaper in the list box, then patch yes to column, right?
If my understanding is right, I have modify my formulas to fit your requirment, please take for reference:
I modify one of items to "NewsPaper", when it is selected, the "YesOrNo" Column(Choices type) will be filled with Yes. If you want to patch a choices to column, you have to patch a record, so use LookUp function to match the record of chocies.
The items property of ListBox:
Table({Value:"A",ID:1},{Value:"Newspaper",ID:2},{Value:"C",ID:3},{Value:"D",ID:4})
The OnSelect of Button:
ClearCollect(col,ListBox1.SelectedItems); Patch(Approvals,Defaults(Approvals),{Title:"Test-1",T1:LookUp(col,ID=1,Value),YesOrNo:If(2 in col.ID,LookUp(Choices(Approvals.YesOrNo),Value="Yes")),T3:LookUp(col,ID=3,Value),T4:LookUp(col,ID=4,Value)})
Hope this can help.
Best regards,
Sik
Hi sik thanks for responding. I actually ended up making a dropdown menu with yes/no that is invisible on the screen. The default dropdown choice was set to yes to be able to pull that yes into my choice column for my sharepoint list and then I did this code.
Newspaper:LookUp(col,ID=2,forPromoMenu.SelectedText),
This allowed me to have a dropdown menu if a user ever has to change their choice within a form. Thanks again for you help! I have been struggling with this and you definitely helped me out!
User | Count |
---|---|
253 | |
106 | |
88 | |
51 | |
43 |