cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
New Member

Global Variables and ThisItem

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)

1 ACCEPTED SOLUTION

Accepted Solutions
Super User III
Super User III

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.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Proud to be a Super User!

Regards,
KrishnaV
Business Applications MVP
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

View solution in original post

8 REPLIES 8
Super User III
Super User III

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.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Proud to be a Super User!

Regards,
KrishnaV
Business Applications MVP
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

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

Kudo Commander
Kudo Commander

@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


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Proud to be a Super User!

Regards,
KrishnaV
Business Applications MVP
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.
Super User III
Super User III

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.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Proud to be a Super User!

Regards,
KrishnaV
Business Applications MVP
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

View solution in original post

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

New Member

@KrishnaV 

 

Here some pictures of the app to hopefully paint a clearer picture 😉 

@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 👍

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Top Solution Authors
Top Kudoed Authors
Users online (62,822)