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 variable value ...
Power Apps
Answered

Global variable value to a button

(0) ShareShare
ReportReport
Posted on by 364 Moderator

I try to pass a value from a global variable to a button. 

 

It works for a boolean value. 
Set(varTrierDirection;true);;

PierreCA_0-1701454264732.png

But fails with a textual value.

 

Set(testMenu;"Some text")

 

PierreCA_1-1701454395500.png

 

Why is that?

 

How to solve it?

 

Categories:
I have the same question (0)
  • OdinDelToro Profile Picture
    407 on at

    Hello PierreCA,

     

    Global variables can be assigned with text values. Nevertheless, the variable on select won't apply a boolean logic. If you run Set(testMenu;"Some text") that will assign the text to the variable. For example, if on the same button you assign to the text property the same variable and you click it you'll be able to visualize its value in the button. 

    OdinDelToro_0-1701457350863.png

    You can also validate that the action of selecting the button works by looking at the global variable.

    OdinDelToro_1-1701457435482.png

    Here is official documentation about the Set function:

    Set function - Power Platform | Microsoft Learn

     

    Now, if that isn't working it can be because the same variable was declared before with a different data type for example if you use another button Set(testMenu;1) and other button with Set(testMenu;"Some text") it will display an error as data types doesn't match Integer vs String so you need to be careful that data types match in those cases.

     

    Hope this helps clarify the doubt, let me know in case you're still facing an issue within it.

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • PierreCA Profile Picture
    364 Moderator on at

    Hello @OdinDelToro 

    The global variable declaration seems fine on my side.

     

    The only difference with your proposition is where I declare my global variable. I do it a the start of the app.

    PierreCA_0-1701458512370.png

    But Power Apps says the variable is kind of empty (vierge = virgin)

    PierreCA_2-1701459352742.png

     

    Then I assing the variable to the text property of the button, but nothing happens. 

    PierreCA_1-1701458916406.png

     

  • Verified answer
    OdinDelToro Profile Picture
    407 on at

    Hello @PierreCA ,

     

    That must be because you need to run the onstart. To run the onstart, you need to select the ellipsis next to the App and then click on Run OnStart. That will run the declared variable and value will appear.

    OdinDelToro_0-1701459707418.png

     

    Hope this helps clarify the doubt, let me know in case you're still facing an issue within it.

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

     

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 207 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 150 Super User 2026 Season 2

Last 30 days Overall leaderboard