cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kyalpha
Regular Visitor

a set Variable on App start problem

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!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-yutliu-msft
Community Support
Community Support

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,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yutliu-msft
Community Support
Community Support

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,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (1,952)