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 / a set Variable on App ...
Power Apps
Answered

a set Variable on App start problem

(0) ShareShare
ReportReport
Posted on by 4

I'm having a strange variable problem, even though I found a walkaround, I still want to know why it's action this way. Here's the context.

 

The primary data source dbo.Incident is SQL via on-premise gateway. I'm setting up 3 variables on App OnStart for later filter use.

 

A: varCurrentUserLogin

> Set(varCurrentUserLogin,First(Split(User().Email,"@")).Result);   

// The Incident Owner(loginID) recorded in dbo.Incident is same as email prefix of Power Apps account.

 

B: varAllTeams

> Set(varAllTeams, SortByColumns(Distinct(Gal_ITPersonnel.AllItems,Team),"Result"))

Each incident owner has a default Team. It's recorded in dbo.Employee. This table has more than 5000 record and I can't collect it. So I build a hidden page and put a filtered gallery to list all IT personnel.  This variable will allow easier dropdown menu.

 

C: varCurrentUserTeam

> Set(varCurrentUserTeam,LookUp(Gal_ITPersonnel.AllItems,LoginID=varCurrentUserLogin).Team)

This pass current user login to gallery and return Team name.

 

theoretically this should work, but I put label to see result, I get:

varCurrentUserLogin: Kevin    //Correct

varAllTeams.Result: List of distinct team names   //Correct

LookUp(Gal_ITPersonnel.AllItems,LoginID=varCurrentUserLogin).Team :  Kevin's Team    //Correct

varCurrentUserTeam:  (blank)    //Sometime it shows correct value on Studio screen, sometimes it doesn't. And I never shows anything on iOS App. Why?

 

At first, I think Set my happen in sequence, so I postpone it to home screen's OnVisable, it's still not working. Then I put it into a button, it's still not working.

 

Now I'm having a label in a hidden page to do the variable work, but why it doesn't work still bugs me.

Hope someone could answer, Thanks a lot!

 

 

Categories:
  • Verified answer
    v-yutliu-msft Profile Picture
    Microsoft Employee on at

    Hi @Kyalpha ,

    Do you mean that?

    1)LookUp(Gal_ITPersonnel.AllItems,LoginID=varCurrentUserLogin).Team

    This could always get correct result.

    2)Set(varCurrentUserTeam,LookUp(Gal_ITPersonnel.AllItems,LoginID=varCurrentUserLogin).Team)

    This could only sometimes get correct result.

    That's really strange...

    Did you put them in the right order?

    Since this formula needs the value of varCurrentUserLogin, so you need to firstly get varCurrentUserLogin.

    You should use order like this:

    Set(varCurrentUserLogin,First(Split(User().Email,"@")).Result); 
    Set(varAllTeams, SortByColumns(Distinct(Gal_ITPersonnel.AllItems,Team),"Result"));
    Set(varCurrentUserTeam,LookUp(Gal_ITPersonnel.AllItems,LoginID=varCurrentUserLogin).Team)

     

    If your app performs not the same in different devices, I suggest you clear the cache, update software to the latest version and try again.

    If the problem still exists, I suggest you open a ticket here:

    https://powerapps.microsoft.com/en-us/support/pro/ticket/

     

     

    Best regards,

  • Kyalpha Profile Picture
    4 on at

    Hi yutliu,

     

    Thanks for the reply.

     

    The issue persists after software update. I'll try to find an elegant solution to read data source before submitting the ticket.

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

#2
WarrenBelz Profile Picture

WarrenBelz 188 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 130

Last 30 days Overall leaderboard