cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper II
Helper II

How to disable data card based on user login in powerapps

I have created a app which is caring with 3 group access, Requester, Approver, Buyer.

 

Each access there are some respective input filed should enter in form. but other input field must disable. but i don;t want to hidden others field.

 

Can some suggest me how to apply this concept please.

 

Thanks 

Sunil

10 REPLIES 10
Super User III
Super User III

Hi @sunilkumar ,

The built-in functions User().FullName and User().Mail can identify who is logged in. If you have a reference table with these details, plus what they can do, you can Lookup the value at App OnStart and then set the Visible/DisplayMode properties of the controls according to this.

 

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.

 

Can you please elaborate more with example...

@sunilkumar 

The idea proposed by @WarrenBelz is 100% and the credit should go to him.  Here's how to implement his idea.

 

1.  Create a new SharePoint list called "MyAllowedUsers"

2.  Create a Person column in the SharePoint list called "Employee".  Do  not allow multiple selections.

3.  Go to PowerApps.  Connect to the MyAllowedUsers datasource.

4.  Use this code in the OnApp start property to find whether the current user is in the list of allowed users

Set(isAllowedUser, !IsBlank(LookUp(myAllowedUsers, Employee.mail = User().Email))

5.  Put this code in the DisplayMode property of the DataCard

If(isAllowedUser=true, DisplayMode.Edit, DisplayMode.View)

 

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Thanks @mdevaney ,

That is pretty much what I would do including the variable, which is useful for testing other things without repeating the test code.


@sunilkumar , I am in a different time zone I suspect (7:00am Friday morning here), so have only got to it now.

 

Sir, 

I have created as you suggested, but it's not meeting my requirement.

Herewith i have explain the my requirements in detailed on enclosed file of reference.

Can you suggest the formula based on my requirements please.

Thanks for your support in advance.

 

Thanks

Sunil

 

 

Super User III
Super User III

Hello @sunilkumar ,

The principle of what myself and @mdevaney have provided is what needs to be done - the difference is that you have a job title rather than a yes/no field.

I will try to do some code with the information you have provided and will rely on you to correct any pieces that may be incorrect assumptions on names.

Firstly, you need to set a Variable for the User's email and job title at App OnStart

Set(vUserMail,User().Email);
Set(
   vUserJob,
   Lookup(
      MyAllowedUsers,
      Lower(E-Mail) = Lower(vUserMail),
      'Job Title'
   )
)

You also have not said whether the two sections at the bottom are separate forms or just more cards on the the same form. If Forms, put this on the FormMode of each

If(
   vUserJob = "Approver",
   FormMode.Edit,
   FormMode.View
)

If these are Cards on the same form, put this on each Card's DisplayMode

If(
   vUserJob = "Approver",
   DisplayMode.Edit,
   DisplayMode.View
)

or set the first one to this and the rest to (I will call the card ApprovalManagerName - change to the actual name).

ApprovalManagerName.DisplayMode

 

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.

Sir, 

All cards are in same the same, just i have divided by section based on user action to just better understand for you.

Thanks @sunilkumar ,

The second code at the bottom (Cards) is what you need.

 

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.

 

If( vUserJob = "Approver", DisplayMode.Edit, DisplayMode.View ) 

 

Sir, This code is not working, error called, invalid argument type.. 

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (5,522)