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 / Hidden Fields and Disa...
Power Apps
Unanswered

Hidden Fields and Disabling the Submit Button

(0) ShareShare
ReportReport
Posted on by 10

Hi!

I am new to this community and Power Apps and feel like I am doing circles and would be grateful for your assistance.

  

Scenario: 

DataCardValue9: Always mandatory

DataCardValue17: mandatory when DataCardValue9 = NCON

DataCardValue14: mandatory when DataCardValue9 = CM

(Attached screenshot for reference)

First, I wanted the two datacards (14 & 17) to hide based on the above criteria and then I wanted to disable the submit button until all fields on the form were completed. 

On the submit button under "DisplayMode"  I put  If(SharePointForm1.Valid,DisplayMode.Edit, DisplayMode.Disabled)

however, this is not working because it’s looking to validate the entire form including both DataCardValue 14 & 17 and one of the fields will always be hidden based on the previous selection.   


Can you please share any insight on how I can make this work?

Thank you so much in advance! 

Form -submit button.jpg
Categories:
I have the same question (0)
  • Ami K Profile Picture
    15,687 Super User 2024 Season 1 on at

    @JMEELYNNE - The Valid property of an Edit Form control is validating the Required property of your DataCards.

     

    With this understanding in mind, I would expect the Required property for the DataCard which contains DataCardValue17 to include something along the lines of:

     

    DataCardValue9.Selected.Value = "NCON"

     

    And Required property for the DataCard which contains DataCardValue14 to include something along the lines of:

     

    DataCardValue9.Selected.Value = "CM"

     

    Note I do not know what you have in the Items property of DataCardValue9. However, the Items property of Dropdown/Combobox controls are typically populated with a single column called 'Value'. Therefore I have used Selected.Value in the above example.

  • jdrm1 Profile Picture
    54 on at

    It sounds like you're building a form where certain fields (DataCardValue14 and DataCardValue17) should only be visible and required under specific conditions, and you want to disable the submit button until all fields are completed. Let's address this step by step.

    1. **Hide DataCardValue14 and DataCardValue17 based on conditions**:
    You can use the `Visible` property of the data cards to control their visibility based on the values of other fields. For example, you can set the `Visible` property of DataCardValue14 to:
    ```
    DataCardValue9.Selected.Value = "CM"
    ```
    And similarly, for DataCardValue17:
    ```
    DataCardValue9.Selected.Value = "NCON"
    ```
    This will hide DataCardValue14 when DataCardValue9 is not equal to "CM", and hide DataCardValue17 when DataCardValue9 is not equal to "NCON".

    2. **Disable submit button until all fields are completed**:
    Your approach to use the `Valid` property of the form is correct. However, you need to consider the visibility of the fields. Since you're hiding DataCardValue14 and DataCardValue17 based on conditions, you need to account for their visibility when checking for validity.

    You can achieve this by checking the `Valid` property of each individual field along with their visibility conditions. For example, if DataCardValue14 is only visible when DataCardValue9 is "CM", you can check its validity only when it's visible:
    ```
    SharePointForm1.Mode = FormMode.New || DataCardValue9.Selected.Value = "CM" && DataCardValue14.Valid
    ```
    Similarly, you can do this for DataCardValue17 if it's only visible when DataCardValue9 is "NCON".

    This way, the submit button will only be enabled when all required fields are visible and filled. Adjust the conditions based on your specific requirements and visibility logic.

  • JMEELYNNE Profile Picture
    10 on at

    Hi @jdrm1 

    Thank you for responding so quickly!  The formula for hiding the fields works beautifully!

    I can't seem to figure out how to combine both of those valid property checks into one long formula on the submit button, I keep getting the red x error, perhaps I am writing it in the wrong property box? I attached another screen shot. 

    I really appreciate your time!

     

    Form -submit button-Formula Error.jpg
  • jdrm1 Profile Picture
    54 on at

    to make it visible/invisible you need to put it in the "visible" field. You have put it into the displaymode field which should be edit. Or are you wanting the button to be always there but only pressable if everything is filled in?

  • jdrm1 Profile Picture
    54 on at

    if you want to use the displaymode field try:

    If(
    SharePointForm1.Valid &&
    (
    (DataCardValue9.Selected.Value = "CM" && DataCardValue14.Valid) ||
    (DataCardValue9.Selected.Value = "NCON" && DataCardValue17.Valid) ||
    (DataCardValue9.Selected.Value <> "CM" && DataCardValue9.Selected.Value <> "NCON")
    ),
    DisplayMode.Edit,
    DisplayMode.Disabled
    )

  • JMEELYNNE Profile Picture
    10 on at

    Thank you again, I tried your suggestion and it says "Valid" isn't recognized - see attached.  

    and to answer your former question, yes I do want the button to be there, just greyed out (disabled) until all of the fields are completed, then it becomes 'clickable'.

    Thoughts? 

     

    Form -submit button-Formula Error2.jpg
  • jdrm1 Profile Picture
    54 on at

    Ok on the form/screen (not the datacards) you should have an onvisible field. 
    try adding;

     

    Set(isDataCardValue14Valid, !IsBlank(DataCardValue14.Text) || DataCardValue9.Selected.Value <> "CM");
    Set(isDataCardValue17Valid, !IsBlank(DataCardValue17.Text) || DataCardValue9.Selected.Value <> "NCON")

     

    For the onchange property on datacardvalue9 try

    Set(isDataCardValue14Valid, !IsBlank(DataCardValue14.Text) || DataCardValue9.Selected.Value <> "CM");
    Set(isDataCardValue17Valid, !IsBlank(DataCardValue17.Text) || DataCardValue9.Selected.Value <> "NCON")

     

    Onchange property for datacardvalue14

    Set(isDataCardValue14Valid, !IsBlank(DataCardValue14.Text) || DataCardValue9.Selected.Value <> "CM")

    Onchange for 17

    Set(isDataCardValue17Valid, !IsBlank(DataCardValue17.Text) || DataCardValue9.Selected.Value <> "NCON")

     

    then try this on the displaymode for the button

    If(
    SharePointForm1.Valid &&
    isDataCardValue14Valid &&
    isDataCardValue17Valid,
    DisplayMode.Edit,
    DisplayMode.Disabled
    )

     

    does that fix it?

  • JMEELYNNE Profile Picture
    10 on at

    Good Morning,  sadly it doesn't fix it, I now have 4 red-x errors.  Thank you for your assistance.  Maybe this scenario is too complex to execute? 

     

  • jdrm1 Profile Picture
    54 on at

    Where are the red X now?

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 536

#2
WarrenBelz Profile Picture

WarrenBelz 426 Most Valuable Professional

#3
Haque Profile Picture

Haque 305

Last 30 days Overall leaderboard