Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building 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.
  • JS-29072031-0 Profile Picture
    10 on at
    Model Driven App Command Button Appearance Depending On Field Values On The Form
    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.
     
  • Tony_Suslovich Profile Picture
    4 on at
    Model Driven App Command Button Appearance Depending On Field Values On The Form
    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
    Model Driven App Command Button Appearance Depending On Field Values On The Form
    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.  
  • Suggested answer
    narayan225 Profile Picture
    2,449 Super User 2025 Season 1 on at
    Model Driven App Command Button Appearance Depending On Field Values On The Form
    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.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,618 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,957 Most Valuable Professional

Leaderboard