So i'm creating my first PowerApp and i'm trying to change a button in a gallery based on some global variables. But it seems i cant set a variable to a value containing ThisItem. Is this not possible or am i doing something wrong? Find my code underneath:
Set(
varSelectedItem, {
Dataset: list_equipmentType,
ButtonText: ThisItem.list_'Equipment Type'
})
(list_equipmentType is a sharepoint list and 'Equipment Type is a column in this list)
Solved! Go to Solution.
Hi @meta_benita,
We see ThisItem mostly in a gallery if so, are you trying to set a variable in a gallery with the below syntax? I am afraid that it will not help you to meet your needs.
Set(
varSelectedItem, {
Dataset: list_equipmentType,
ButtonText: ThisItem.list_'Equipment Type'
})
I can help you, if you could elaborate more on the requirement to set this value in a gallery.
Regards,
Krishna
If this post helps give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.
Proud to be a Super User!
Regards,hi @meta_benita ,
Set syntax is Set(variableName,value) what you are using is for UpdateContext({varName:value1,varName2:value2....}).
try with Set syntax that will work.
I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to help.
Regards,
Krishna
If this post helps give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.
Proud to be a Super User!
Regards,hi @KrishnaV,
Thanks for the quick response. However hen i use a comma in the Set syntax i get an error saying unexpected characters. Also in my example Dataset: list_equipmentType does work. 🤔
@meta_benita I think the problem is, that you want to do this:
Dataset: list_equipmentType
I think you cannot give a SharePoint-List-object reference in this context to a variable.
@KrishnaV : sorry, but I’m think you are wrong.
you can use set(VarName,{ID:1,Color:”Red”}) also with records.
https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-set#examples
Hi @max81 ,
I agree we can implement but the point here is that syntax is handier when we implement a collection. Set we use to set a single value as a global variable absolutely not for records.
Having said that @meta_benita : Let me know if you need any further help on this issue.
Regards,
Krishna
Proud to be a Super User!
Regards,Hi @meta_benita,
We see ThisItem mostly in a gallery if so, are you trying to set a variable in a gallery with the below syntax? I am afraid that it will not help you to meet your needs.
Set(
varSelectedItem, {
Dataset: list_equipmentType,
ButtonText: ThisItem.list_'Equipment Type'
})
I can help you, if you could elaborate more on the requirement to set this value in a gallery.
Regards,
Krishna
If this post helps give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.
Proud to be a Super User!
Regards,@KrishnaV yes im using it in a gallery. I will do my best to explain the problem im trying to solve by this.
I have a form and one of the fields needs to be a multiple choice to which the user could add extra options and later users could also select the "new extra options".
To achieve this i have a "main" sharepoint list for the data in the form, and a couple "sub" lists, for the extra options.
In my current setup i've made an extra screen with a gallery with a buttons (based on the options in a "sub database". If a user clicks on this it submits the answer to the "main list" and an input field which if it is submitted adds its value to a '"sub" list.
@KrishnaV i found a solution trying something else.
In my sharepoint list ive made changed the "multiple choice" answers from a text input to a choice input with manual values allowed. Then generated a new list in a new app. This gave me choicefields with input fields and with this code in the update field it allowed me to add values and fetch them later. Way easier than the way is was thinking 🙂
Anyway, thanks for the help 👍
User | Count |
---|---|
196 | |
125 | |
86 | |
49 | |
42 |
User | Count |
---|---|
284 | |
159 | |
138 | |
75 | |
72 |