Hi PowerApps Team!
I have a button that when clicked navigates to a screen with sensitive data. This screen is currently password protected.
Would it be possible to utilise the User().FullName function instead of password protecting?
My idea was that if User().FullName exists in a column in my sharepoint list then they can access the screen, otherwise they can't.
I tried doing an if statement:
=if (UserFullNamelbl.Text = LookUp( UsernameDatabase, UsernameColumn = UserFullNamelbl.Text ), navigate(screen2))
UserFullNamelbl.Text is a lbl equal to User().FullName
Unfortunately PowerApps does not seem to like this code.
Thanks everyone!!
D
Solved! Go to Solution.
OK @milky_bar_may ,
Firstly isBlank has a capital B.
You also have to make sure the second bit works
Set(
vAuthUser,
LookUp(
UsernameDatabase,
UsernameColumn = vUserName,
UserNameColumn
)
);
Is your list names UsernameDatabase and your field with the user name UserNameColumn?
You can also use
Set(
vAuthUser,
LookUp(
UsernameDatabase,
UsernameColumn = vUserName
).UserNameColumn
)
Hi @milky_bar_may ,
User functions as not Delegable, so as a precaution, set a Variable at App Onstart and also see if user is in list
Set(
vUserName,
User().FullName
);
Set(
vAuthUser,
LookUp(
UsernameDatabase,
UsernameColumn = vUserName
)
)
Then - if they are there (I am assuming this is the test you need)
If(
!isBlank(vAuthUser),
Navigate(screen2),
Whatever you do for other users
)
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
Hi @WarrenBelz
Many thanks for the reply.
Unfortunately it did not work.
I followed your instructions, putting the code in OnStart and then on my button.
However when I clicked the button nothing happens. It doesn't navigate me to the second screen.
I am not an PowerApps expert so am definitely scratching my head and don't have alternative ideas
Thanks
D
Hi @milky_bar_may ,
The code should have returned a table, which should work, but try this using the field name in the SharePoint list. I assume the list and field names are correct.
To test, put this on a button on screen 1. Also put in a label with the Text property vAuthUser and see what is there.
Set(
vUserName,
User().FullName
);
Set(
vAuthUser,
LookUp(
UsernameDatabase,
UsernameColumn = vUserName,
UserNameColumn
)
);
If(
!isBlank(vAuthUser),
Navigate(screen2),
Notify("User is not authorised",NotificationType.Error)
)
Hi @WarrenBelz ,
Many thanks for your response.
On further investigation it says '!isblank(vAuthuser)' is invocation of unknown or unsupported function.
Try
Set(
vAuthUser,
LookUp(
UsernameDatabase,
UsernameColumn = vUserName
).UserNameColumn
OK @milky_bar_may ,
Firstly isBlank has a capital B.
You also have to make sure the second bit works
Set(
vAuthUser,
LookUp(
UsernameDatabase,
UsernameColumn = vUserName,
UserNameColumn
)
);
Is your list names UsernameDatabase and your field with the user name UserNameColumn?
You can also use
Set(
vAuthUser,
LookUp(
UsernameDatabase,
UsernameColumn = vUserName
).UserNameColumn
)
Hi @milky_bar_may :
Do you want to implement the following functions:
Can you tell me:
I assume the datatype of “UsernameColumn” is “Text”.
I made a test but didn’t encounter the error. Here is my solution for your reference:
Add a button and set it’s OnSelect property to:
Set(vUserName,User().FullName); /* If you don't care whether it is delegable, you can use User().FullName directly */
If(
!IsBlank(
LookUp(
UsernameDatabase,
vUserName = UsernameColumn
)
),
Navigate(Screen2)
)
By the way, this item needs your attention:
Best Regards,
Bof
Hi @HadynM , @WarrenBelz , @v-bofeng-msft
Many thanks to you all - you were all extremely helpful and the solution now works.
Thanks
D
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
186 | |
52 | |
50 | |
34 | |
33 |
User | Count |
---|---|
267 | |
97 | |
84 | |
72 | |
71 |