web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Global Variables and T...
Power Apps
Answered

Global Variables and ThisItem

(0) ShareShare
ReportReport
Posted on by 16

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)

Categories:
  • KrishnaV Profile Picture
    5,023 on at

    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.

  • meta_benita Profile Picture
    16 on at

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

  • max81 Profile Picture
    860 on at

    @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

     

  • KrishnaV Profile Picture
    5,023 on at

    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

  • Verified answer
    KrishnaV Profile Picture
    5,023 on at

    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.

  • meta_benita Profile Picture
    16 on at

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

  • meta_benita Profile Picture
    16 on at

    @KrishnaV 

     

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

    Naamloos2.jpg
    Naamloos.jpg
  • meta_benita Profile Picture
    16 on at

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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 381 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 340

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard