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!