I'm trying to work out the new StartScreen property in App.
Previously my formula on App.OnStart was:
Set(loggedUserEmail,Office365Users.MyProfileV2().mail);
Set(varDPA, If(LookUp(Permissions, loggedUserEmail in Person.Email, true), true, false));
If(LookUp(ProjectRegister, loggedUserEmail = Author.Email || loggedUserClaims in IAO.Email, true), Navigate('Home Screen'), Navigate('Welcome Screen'))
I removed the last line of code from OnStart and added this to StartScreen:
If(LookUp(ProjectRegister, Or(loggedUserEmail = Author.Email, loggedUserEmail = IAO.Email), true), 'Home Screen', 'Welcome Screen')
However, I get the error message that global variables aren't allowed in the StartScreen property.
I see we have to use named formulas but what I tried didn't work. I guess I could replace loggedUserEmail with Office365Users.MyProfileV2().mail but then it would be querying it more than once.
My global variable loggedUserEmail is also used for looking up varDPA so it doesn't make sense not to use it again.
What is the best thing to do here?
Solved! Go to Solution.
You could use the With function in stead of a global variable :
With({loggedUserEmail: Office365Users.MyProfileV2().mail},
If(LookUp(ProjectRegister, loggedUserEmail = Author.Email || loggedUserEmail = IAO.Email, true), 'Home Screen', 'Welcome Screen'))
Please consult the StartScreen property detalied documentation.
You cannot refer to global variables of the app inside this property even if they are defined in OnStart property of the same app.
Hope it helps !
Hi @gabibalaban
Thank you for this.
So going by the documentation I would need to use the User() function to compare to the user in my data source.
The problem with this is that our User().Email function brings up a different email address in our business to the one saved in a people picker. I've found the only way to make the correct comparison and avoid a delegation warning is to use Office365Users.MyProfileV2().mail.
However I get a delegation warning when querying Office365Users in StartScreen using this formula:
I don't get a delegation warning if I use a similar formula but reference the variable in the OnStart:
I'd really like to avoid delegation altogether in this app, so any ideas of how to get around this issue would be appreciated.
You could use the With function in stead of a global variable :
With({loggedUserEmail: Office365Users.MyProfileV2().mail},
If(LookUp(ProjectRegister, loggedUserEmail = Author.Email || loggedUserEmail = IAO.Email, true), 'Home Screen', 'Welcome Screen'))
The @shoog solution works, with a small observation. As we talk about StartScreen property, the formula needs to return a screen name, not an action (like Navigate() ). So the formula you need is ...
With(
{loggedUserEmail: Office365Users.MyProfileV2().mail},
If(
LookUp(ProjectRegister, loggedUserEmail = Author.Email || loggedUserEmail = IAO.Email, true),
'Home Screen',
'Welcome Screen'
)
)
Please accept @shoog 's reply as solution as it shows us the way to solve the issue.
Thanks for spotting that @gabibalaban , I forgot to change that part. Updated my post accordingly.
Thank you both. That works well.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
188 | |
70 | |
50 | |
37 | |
25 |
User | Count |
---|---|
240 | |
112 | |
91 | |
91 | |
68 |