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!
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.
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,