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

Why my variable value on a label only shows on the second go?

(0) ShareShare
ReportReport
Posted on by 387

Hi PA veterans,

 

I have a series of onStart global variables coded in the following fashion:

Set(varClientName,  "");

Set(varClientEmail,  ""); etc

 

I want to click the 'Show Info' button and see the the value of varClientName on the label. For testing purpose, I've created a label  to check if the value is returned correctly (original gallery.selected value vs. the variable value). However, the value of varClientName 'John Smith' will only appear on the second click. This is the same for all my other variables. May I know where I've done wrong and how to fix it?

PA issues.jpg

 

Thank you in advance.

 

Categories:
  • PowerRanger Profile Picture
    3,458 Super User 2024 Season 1 on at

    @Australia 

    Have you tried closing and re-opening the App? I tried this on my side exactly as you described and I can't reproduce your issue. 

  • PowerRanger Profile Picture
    3,458 Super User 2024 Season 1 on at

    @Australia Did it re-opening the app solved your issue

     

    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.

  • Australia Profile Picture
    387 on at

    @PowerRanger Thanks for the help. 🙂
    I might have finally figured it out.  I think I have too many set variables in the OnSelect of the button so I used the 'Concurrent' function to bundle all the set variables and it appears to have worked. 🙂
    e.g. Concurrent(
    Set(galClientName.Selected.ClientName.DisplayName,varClientName),
    Set(galClientName.Selected.ClientEmail.Email,varClientEmail),

    ......

    );

     

    Hope this post helps anyone who have experienced similar issues in the future.

     

  • PowerRanger Profile Picture
    3,458 Super User 2024 Season 1 on at

    @Australia is there a specific reason why you store each value in a single variable?

     

    Why don’t you save the complete record into a single variable?

     

    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.

  • Australia Profile Picture
    387 on at

    @PowerRanger because I am an amateur... 😂  Could you kindly teach me how I can save the complete record into a single variable?  Let me know if I need to update the OnStart global variables, too. 🙂

     

  • Australia Profile Picture
    387 on at

    @PowerRanger hi again, no unfortunately. I tried multiple times, re-starting the app did not solve the issue.

  • PowerRanger Profile Picture
    3,458 Super User 2024 Season 1 on at

    @Australia 

    You could just write

    Set(varSelectedItem,galClientName.Selected)

     

    This will save the entire record in a variable and you can reference it anywhere you want. This formular could be used in the OnSelect property of your Gallery. In That case (using theOnSelect Property of your Gallery) you could even say

     

    Set(varSelectedItem,ThisItem)

     

    So now, on a label Text-Property you could say e.g. 

     

    varSelectedItem.ClientName.DisplayName

     

    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.

  • Australia Profile Picture
    387 on at

    @PowerRanger Wow amazing!

    So just to confirm here is what I need to do:

    1. App OnStart  -  do nothing

    2. Gallery OnSelect - Set(varSelectedItem,ThisItem)

    3. Button OnSelect - Set(varSelectedItem,galClientName.Selected)

    4. Label Text - varSelectedItem.ClientName.DisplayName or varSelectedItem.ClientEmail.Email or varSelectedItem.ClientPhone so on and so forth?

     

  • Verified answer
    PowerRanger Profile Picture
    3,458 Super User 2024 Season 1 on at

    @Australia correct

     

    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.

  • Australia Profile Picture
    387 on at

    Fantastic. Many thanks PowerRanger. Go Go PowerRangers.

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 226 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 191 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 167

Last 30 days Overall leaderboard