I have one SharePoint List and one Form in PowerApps.
The list has just one column 'Name'.
How do I get the following If statement to work in the Form DisplayMode property?
If the name of the current logged-in user (varUserName) = name on the SP list, DefaultMode.View otherwise Edit
Name = varUserName
It does not work. :'(
Solved! Go to Solution.
IsEmpty() determines if a table does not contain any values and is typically used with a Filter() function. IsBlank() determines if a record exists and is typically used with Lookup(), as this function looks for a single record matching the criteria. .
Well, there are issues with both your LookUp function and your If function.
What do you want to achieve with your LookUp function? Do you simply want to check if a record exists in your SharePoint list for that user?
Bear in mind that an If function has 3 arguments. The first argument needs to return either true or false (its a logical test). The second argument is what the If function will return if the first argument returns true. The third argument is what the If function will return if the first argument returns false.
Right now your first argument will return a record from SharePoint, which is not true or false. Your second and third arguments are the same, meaning that the return of your whole If function will always be Displaymode.View, regardless of whether the first argument returns either true or false.
@zmansuri Thanks for the prompt reply and suggestions. Much appreciated.
I am sorry but the OnStart script returns a red line, it seems that 'Name' could be found. Even though it's on the SP list. I made sure the list name is correct and I even refreshed the list in the data tab.
Invocation of unknown or unsupported function.
Name isn't valid. This identifier isn't recognized.
Did I do anything wrong?
@KvB1 Thanks for the prompt reply.
You are correct, essentially the SP list is a list of auditors with names.
The displaymode of the Form is determined by this list.
If your name is on the auditors list then you can only view the form (DefaultMode.View), otherwise DeafaultMode.Edit.
Hope it clarifies.
If( !IsEmpty( LookUp( 'SharePoint List', Name = varUserName ),
Try this for your logical test. I'm sure you can figure out what to put for the second and third arguments in the IF function ^^
Basically, IsEmpty will return true if the record you are trying to find isn't there. By putting the ! in front of that we reverse that, so it will return true if there is a record found. We use the LookUp that you provided to give input to the IsEmpty.
So if there is a record found that meets the requirements of your LookUp, the first argument of the IF function will return true.
@KvB1 Thanks mate.
Here's my attempt but the whole thing was highlighted in red. :'(
Name = varUserName)),
Well, what does it say? 😄 The obvious problem is that 'SharePoint List' isn't the actual name of the sharepoint list you want to use
Yes I know that, I use 'SharePoint List' just as a disguised name for the ease of conversation.
I think it's my syntax that is wrong somewhere causing the error.
Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.
Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.
Check out the new Power Platform Community Connections gallery!