cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Form to 'Read Only' based on Status value column and lookup list

We have a work order custom list with status column:

Open
On Hold

Approved

Closed

 

We are looking for opportunity to only allow users in a SharePoint Lookup list called:

ApprovalUsers

...with a text field

ApproverEmail

 

...to edit the item when status is "Approved".  The spirit is if the work order has gone to "Approved", we only want a small amount of users to be able to edit the list item going forward.

 

Something to affect of App.OnStart event 

...If(LookUp(ApprovalUsers,User().Email=ApproverEmail,ApproverEmail)=User().Email...

 

Not sure if this is an option to set entire edit form to 'Read Only'...or individual fields...b/c we only want "approvers" to edit from this point forward.

 

8 REPLIES 8
poweractivate
Super User II
Super User II

@Anonymous 

 

Yes it should be possible in one or more ways.

 

You can try this way which could be easier:

 

Try to set the Form DefaultMode to FormMode.View or FormMode.Edit using your If statement

FormMode.View to "disable" it for editing

FormMode.Edit  to "enable" it for editing

v-xida-msft
Community Support
Community Support

Hi @Anonymous ,

Do you want to make the Edit form to be "Editable" for some amount of users when the Status column value is set to "Approved"?

 

If you want to make the entire Edit form to "Read-Only" in your app, I afraid that there is no direct way to achieve your needs in PowerApps currently. As an alternative solution, you need to make individual data cards in your Edit form to "Read-Only".

 

I have made a test on my side, please consider take a try with the following workaround:

Unlock each data card in your Edit form, set the DisplayMode property of data card to following:

If(
   ThisItem.Status.Value = "Approved" && IsBlank(LookUp(ApprovalUsers, ApproverEmail = User().Email)),
   DisplayMode.Disabled,
   DisplayMode.Edit
)

Note: Please apply above formula to each data card in your Edit form.

 

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

If I take this portion out, it will work for the data card being in 'Read Only':

&& IsBlank(      LookUp(         ApprovalUsers,      ApproverEmail = User().Email  )

 

I have the datasource ApprovalUsers, and the list has:

ApproverEmail field as Single line of text

 

Not sure why the lookup is failing

Appears the Lookup() is a bit inconsistent from what I found via this post...and could be why my testing even with refreshing the data and form still wasn't working properly:

https://powerusers.microsoft.com/t5/Building-Power-Apps/LookUp-function-only-working-sometimes/td-p/...

 

...so, I ended up using First(Filter()) and it's working when switching back and forth + refreshes to test my data:

 

If(
DataCardValue4.Selected.Value = "Approved" && !IsBlank(
First(Filter(ApprovalUsers, ApproverEmail = User().Email)).ApproverEmail
),
DisplayMode.Edit,
DisplayMode.Disabled
)

yashag2255
Dual Super User II
Dual Super User II

Hi @Anonymous 

 

If this is similar to the post: https://powerusers.microsoft.com/t5/Building-Power-Apps/Dropdown-values-filtered-by-who-is-logged-in/td-p/441533 

Can you try to use the expression:

ClearCollect(StatusValues,{Value:"Open"},{Value:"On Hold"},{Value:"Closed"});If(CountRows(Filter(ApprovalUsers, ApproverEmail = User().Email))> 0,Collect(StatusValues,{Value:"Approved"}))

Now, use the StatusValues collection in the Items property of the dropdown.

Note: Do not forget to trigger the "OnStart" in the Edit mode.

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

What's odd is I only see the 3 values when I go to View >> Collections and when testing:

Open
On Hold
Closed

 

For the App >> OnStart I have the following:

ClearCollect(
StatusValues,
{Value: "Open"},
{Value: "On Hold"},
{Value: "Closed"},
{Value: "Approved"}
);
If(
!IsBlank(
First(Filter(ApprovalUsers, ApproverEmail = User().Email)).ApproverEmail
),
Collect(
StatusValues,
{Value: "Approved"}
),Collect(StatusValues, {Value: "UserNameNotFound"}
)

 

 

The data source and items properties for this dropdown are set to the collection StatusValues

Hi @yashag2255 , what do you mean OnStart for Edit mode?

I see there's an OnStart for the app level.

How do I trigger this in Edit mode?

 

I have the following for OnVisible for the NewItemScreen to test the concept/code.
Would this work in OnVisible just for the NewItemScreen?
Seems like there's a caching time for the collection as when I make changes, it's not reflected until I close browser, etc:

 

ClearCollect(
StatusValues,
{Value: "Open"},
{Value: "On Hold"},
{Value: "Closed"}
);
If(
!IsBlank(
First(Filter(ApprovalUsers, ApproverEmail = User().Email)).ApproverEmail
),
Collect(
StatusValues,
{Value: "Approved"}
),Collect(StatusValues, {Value: "UserNameNotFound"}
))

Hi @solwebsolutions 

 

Yes I mean to add the expression on the OnStart of the App. It is not triggered automatically when you place the expression on the OnStart property, this should be done manually for the current session. If you save it and reopen the app, the collection will be filled automatically. In this case, you need to trigger the OnStart by following below steps:

Select App from the left menu, then click on the three dots beside it and then select Run OnStart, this way the collection will be populated with the values.

dwq.png

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,321)