web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Model Driven App Comma...
Power Apps
Suggested Answer

Model Driven App Command Button Appearance Depending On Field Values On The Form

(0) ShareShare
ReportReport
Posted on by 10
I’ve created a model driven app that has a solution containing a table named Investment.  On the main form for the Investment table, there is a field named Assigned_Reviewer.  The Assigned_Reviewer is a look up field to the Role table Name (primary) field.
At the top of the Investment Main form is a command button that says Approve.
Here is what I need to know how to do:
When the user viewing a record on the Investment Main form is the same person specified in the Assigned_Reviewer field, I want the Approve command button to be visible and active.  Otherwise, I want the Approve command button to be invisible or inactive.
I need the java script to get current user, which I’m assuming will run for the Investment Main form On Load event, but more importantly, I need the fx code that will compare the current user to the Assigned_Reviewer and then control the appearance of the Approve command button.
Categories:
I have the same question (0)
  • Suggested answer
    narayan225 Profile Picture
    2,547 Super User 2025 Season 2 on at
    Just change the part where you check for the field in the form.
     
    Instead of checking an option set, check for a lookup field.
    Hope this helps.
  • JS-29072031-0 Profile Picture
    10 on at
    Thank you Narayan for that suggestion, however, I'm looking for help on how to compare the current user of the app to the person listed in the Assigned Reviewer field.  Then, based on whether the current user and the Assigned Reviewer match, make the command button visible or not.  
  • Tony_Suslovich Profile Picture
    4 on at
    Hi @JS-29072031-0, I know it's been almost 2 months since you asked this question, but have you been able to make this work? I'm facing a similar dilemma and tried using User().Email to compare the logged-in user to a value in a lookup field on the form, but I couldn't get User() to work. I have a feeling it just doesn't work for model driven apps, only for canvas apps.
  • JS-29072031-0 Profile Picture
    10 on at
    In the end, I chose not to use a command button in part because I couldn't ascertain the current user via FX code in my model driven app as easily as a canvas app.  So instead, I added an Approved Yes/No field to my Investment table, and used java script, on the form's On Load event, to compare the current user to the assigned user, to determine whether the Approved Yes/No field is locked or unlocked.  If you're not comfortable writing java script: If you clearly describe in detail what you need the script to do, Chat GPT (Openai.com) will do a fairly good job of writing the script for you.  Usually some tweaking is needed, but it can be a huge help.
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard