Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Help with DisplayMode if certain fields are visible or visible and empty

(0) ShareShare
ReportReport
Posted on by 90

Hey everyone!

I would like some help with the display mode of a button.

I have a form that's connected to a SharePoint list that has some columns in it. I also have a button that has an if statement on the DisplayMode property that checks if each field in the form is empty. If any of them are empty, set the DisplayMode to disabled, else DisplayMode is set to edit. The purpose of this button is to make it so they cannot continue on in the app unless all fields in the form have a value or have something selected.

Now, I have some fields that are not visible to everyone who will be using this app. In essence, a LookUp is done in another SharePoint list to see if they have direct reports or not. If they do, some other fields are visible to them. I would like these to also be included in the DisplayMode if statement check on the button but only if they're visible. How would I do this?

Also, if there's a cleaner way input checking in PowerApps I am happy to change my code on the button because it would help with other projects for the future too!

Thank you!

  • jojos_iq Profile Picture
    90 on at
    Re: Help with DisplayMode if certain fields are visible or visible and empty

    A marked your answer as a solution as it's also a very important thing to make sure you do as well imo - thank you for the assistance, Tony 🙂

  • Verified answer
    Tony_Bowes_BP Profile Picture
    280 on at
    Re: Help with DisplayMode if certain fields are visible or visible and empty

    Yep, the additional outcome of leveraging the inbuilt validation logic system is that you get timely, contextual error handling (red-bordered fields around missing values, validation help text) when they attempt to submit an invalid form. The only thing is that if you are disabling the submit button until all valid fields are filled, you don't get the red-bordered error handling upon submit. You will need to consider how you let the user know WHY they can't submit the form (Eg: User sees the button disabled, but doesn't know what they need to do to make the button work, is it broken? Is it always supposed to be disabled? Is it permissions?). How you let the user know what they need to do next will depend on the skill of the user and how valuable they see the data that they are entering / validating. The main thing is to make sure the validation method improves the user experience. 

  • Verified answer
    jojos_iq Profile Picture
    90 on at
    Re: Help with DisplayMode if certain fields are visible or visible and empty

    Okay so I solved it in a much more seamless way. Here are the steps:

    - on the button, in the DisplayMode field I have this code:

    If(initialInfoForm.Valid, DisplayMode.Edit, DisplayMode.Disabled)

    - I have code set in the Required field of the two data cards set Required to true if it is visible:

    If('Temporary Datacard_1'.Visible, true, false)

    Testing the code it behaves as required:

    - when the two fields are NOT visible, they do not influence what the DisplayMode of the button will be

    - when the two fields ARE visible, they are required to have values otherwise they will not be able to click the button!

  • Tony_Bowes_BP Profile Picture
    280 on at
    Re: Help with DisplayMode if certain fields are visible or visible and empty

    Because your initial logic is negative (If any of these things are true, disable). It's possibly cleaner to check for the optional values in the same statement, but combine them with the .visible check. Something like: 

    //NOTE: Untested code
    If(
     varError = true || IsBlank(leaverDropdown.SelectedItems) || IsBlank(mgrDropdown.Selected) || IsBlank(ctrEndDate.SelectedDate) || IsBlank(lastworkingDate.SelectedDate) || IsBlank(resignationType.Selected.Value) || IsBlank(tlDropdown.Selected.Value) || ((TempOrPermSelector.Visible = true) && (IsBlank(TempOrPermSelector.Selected.Value))) || 
     ((newTLSelector.Visible = true) && (newTLSelector.Selected.DisplayName = Blank())),
     DisplayMode.Disabled,
     DisplayMode.Edit
    )

     

  • jojos_iq Profile Picture
    90 on at
    Re: Help with DisplayMode if certain fields are visible or visible and empty

    Ahhh I seemed to have jumped the gun. I am not too sure if it's because of how big of a statement it is or not but it's still not working 😞 below is my code:

    If(
     varError = true || IsBlank(leaverDropdown.SelectedItems) || IsBlank(mgrDropdown.Selected) || IsBlank(ctrEndDate.SelectedDate) || IsBlank(lastworkingDate.SelectedDate) || IsBlank(resignationType.Selected.Value) || IsBlank(tlDropdown.Selected.Value) || TempOrPermSelector.Visible = true || newTLSelector.Visible = true,
     If(
     IsBlank(TempOrPermSelector.Selected.Value) || newTLSelector.Selected.DisplayName = Blank(),
     DisplayMode.Disabled,
     DisplayMode.Edit
     ),
     DisplayMode.Edit
    )

     
    I was too quick to the draw and am hoping it is okay get further help. Thank you!

  • jojos_iq Profile Picture
    90 on at
    Re: Help with DisplayMode if certain fields are visible or visible and empty

    Omg I didn't even think about doing a nested if statement to perform the check! Thank you kind person 🙂

  • Tony_Bowes_BP Profile Picture
    280 on at
    Re: Help with DisplayMode if certain fields are visible or visible and empty

    Hi Jojos,

    You should be able to check the status of the .Visible attribute and use that to help decide whether to check the value itself.

     

    Here's an example of controlling the DisplayMode of a button by checking the visibility of a manual TextInput first. If it's not visible you can press the button regardless of the value in the TextInput control. IF the control is visible, then it only allows pressing when there is a value entered: 

    If (
     ManualTestInput.Visible,
     If(
     IsBlank(ManualTestInput.Text),
     DisplayMode.Disabled,
     DisplayMode.Edit
     ),
     DisplayMode.Edit
    )

     

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,524 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,906 Most Valuable Professional

Leaderboard