Skip to main content
Community site session details

Community site session details

Session Id : kH4QkwxuvlMg4d2PzcpXoM
Power Apps - Building Power Apps
Answered

a set Variable on App start problem

Like (0) ShareShare
ReportReport
Posted on 17 Jun 2020 06:09:31 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:
  • Kyalpha Profile Picture
    4 on 26 Jun 2020 at 10:21:42
    Re: a set Variable on App start problem

    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.

  • Verified answer
    v-yutliu-msft Profile Picture
    on 18 Jun 2020 at 05:44:01
    Re: a set Variable on App start problem

    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,

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Loading complete