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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to Disable a form ...
Power Apps
Unanswered

How to Disable a form based on a field value

(0) ShareShare
ReportReport
Posted on by 71

Hey All,

 

OK once again doing something I think should be incredibly straight forward and easy, but I must be missing something on order of operations.  I want to control the display mode of a form (on load) based on the value of a field in the form. 

 

So, before displaying the form, I want to check the value of the status field.  If the Status field = "Rejected" I want to ViewForm.  Else, I want to EditForm.    I looked up another similar scenario, and they were using a Lookup on the record they wanted to display to check the field value before doing the EditForm/ViewForm.   This can't be the only solution, can it?

 

TIA,

Troy

 

Categories:
  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @TeeroyLyon 

    This should happen when you navigate to the screen.

    If(Status="Rejected", ViewForm(FormName), EditForm(FormName)); Navigate(Screenname);

     

    Example

    StalinPonnusamy_0-1626794044114.png

     

  • BCLS776 Profile Picture
    8,994 Moderator on at

    You're on the right track. Put the following code into a property that will run behavior formulas, such as OnVisible for a screen or OnSelect for a button:

    If (Status = "Rejected", ViewForm(myFormName), EditForm(myFormName))

    Assuming Status is a value you already have in your hands (a variable or control value)

  • TeeroyLyon Profile Picture
    71 on at

    Hey @StalinPonnusamy, thanks for the quick response.  Yes via OnSelect, is no problem.  I'm trying to do this through @BCLS776 OnVisible suggestion.   In my OnVisible I have:

     

    If(Or(GovSponsorApproveActionHere.Selected.Value="Rejected",EPICSMEApproveActionHere.Selected.Value="Rejected"),true,false);

     

    These names represent the control names.  But when I use this statement, both fields are blank.  On the form, one of these has the "Rejected" value. 

     

    Thanks!

  • BCLS776 Profile Picture
    8,994 Moderator on at

    @TeeroyLyon wrote:

    Hey @StalinPonnusamy, thanks for the quick response.  Yes via OnSelect, is no problem.  I'm trying to do this through @BCLS776 OnVisible suggestion.   In my OnVisible I have:

     

    If(Or(GovSponsorApproveActionHere.Selected.Value="Rejected",EPICSMEApproveActionHere.Selected.Value="Rejected"),true,false);

     

    These names represent the control names.  But when I use this statement, both fields are blank.  On the form, one of these has the "Rejected" value. 

     

    Thanks!


    Your If statement is returning either a true or a false - that won't change the form control's mode. You'll need to use the ViewForm() and EditForm() function calls to change the form's mode.

  • TeeroyLyon Profile Picture
    71 on at

    Oh sorry, the true and false are just for reference,   my If statement actually calls the ViewForm and EditForm,  My full if statement is as follows:

     

    If(Or(GovSponsorApproveActionHere.Selected.Value="Rejected",EPICSMEApproveActionHere.Selected.Value="Rejected"),ViewForm(IDEARequestForm),EditForm(IDEARequestForm));

     

    But this seems "cart before the horse".  Are the field values populated only after I call the EditForm or View Form?

     

    Thanks again for your help.

  • BCLS776 Profile Picture
    8,994 Moderator on at

    @TeeroyLyon wrote:

    .

    .

    .

    But this seems "cart before the horse".  Are the field values populated only after I call the EditForm or View Form?

    No, calling EditForm or ViewForm does not necessarily populate the form fields with data. The form must already be connected to a data source, and then its Items property will determine which record is currently displayed.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 221 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 188 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 120

Last 30 days Overall leaderboard