cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Nunzie
Helper III
Helper III

Hide Field Based On Value of Another - Using Multiple Form Modes

Hello,

Wondering if I could get some assistance. I have a one page power app. On the left a gallery, on the right a form that is default to View mode. I have a button that then changes the Form to Edit mode allowing users to add a new record. What I'm trying to do is hide Field 3 when the Value of Field 1 is not "Travel" (field 1 is a drop down based on values defined in SharePoint list). I had used 'Request Type'.Value = "Travel" on the visible property of Field 3 which worked great on the view mode, but it did not re-appear when I was in Edit mode trying to add a new record and selecting Travel from the drop down. Just wondering if there is an additional instruction I need to add.  Thanks in advance for any help provided.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Try these 6 combinations as your criteria does not seem to be clear to me:

If you want it to work in any form mode:

 DataCardValue1.Selected.Value = "Travel"

Or

DataCardValue1.Selected.Value <> "Travel"

 

If you want it to work in View form mode:

If(Form1.Mode=FormMode.View&& DataCardValue1.Selected.Value = "Travel" ,true,false)

Or

If(Form1.Mode=FormMode.View&& DataCardValue1.Selected.Value <> "Travel" ,true,false)

 

If you want it to work in View and New form mode:

If(Form1.Mode<>FormMode.Edit&& DataCardValue1.Selected.Value = "Travel" ,true,false)

Or

If(Form1.Mode<>FormMode.Edit&& DataCardValue1.Selected.Value <>"Travel" ,true,false)

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

 

View solution in original post

12 REPLIES 12
eka24
Super User
Super User

Use this formula 

FormName.Mode=FormMode.New&& 'Request Type'.Value = "Travel" 

Or

FormName.Mode<>FormMode.New&& 'Request Type'.Value <> "Travel" 

 

Or

If(FormName.Mode=FormMode.New&&
'Request Type'.Value = "Travel" ,false,true)

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Sorry those don't work. They aren't putting the fields visible when someone selects travel from the drop down in Request Type. They also always remain hidden in View mode. I tried all three variations.

Use this formula 

If(FormName.Mode=FormMode.New&&
'Request Type'.Selected.Value = "Travel" ,false,true)

 

I left out the SELECTED

Request Type'.Selected.Value = "Travel" 

 

The idea is It should be hidden only on New enteries and Select is Travel?

 

Please show the items of the Dropdown if it doesn't work

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Nope, still nothing. And no, if Travel is selected, it should show, so I just swapped the true false. Also, it has a red X for an error. It doesn't show at all after selecting Travel. I need it in view mode to be visible if the Request Type was travel, and I need the field to appear to fill in details if the Form is new and request type chosen is Travel from drop down.

 

The code I used is on Visible is: (I presume I can put it on the main data card for the field?)

If(Form1.Mode=FormMode.New&&'Request Type'.Selected.Value = "Travel" ,true,false)

 

I have attached screenshots. On the View Image, you will see the entry is not travel, therefore I'd like to hide the two fields circled in yellow, Travel Destination and Overnight.

 

In the second screenshot it shows how the Travel Destination field which i have the formula on does not appear after Travel has been selected from the Request Type Dropdown.

 

From your request:

"I had used 'Request Type'.Value = "Travel" on the visible property of Field 3 which worked great on the view mode, but it did not re-appear when I was in Edit mode trying to add a new record and selecting Travel from the drop down."

 

1. It means when you use: 'Request Type'.Selected.Value = "Travel" , it works fine.

2. That should work in edit mode as well. The pictures you showed are all in view mode not Edit mode. You are trying to change the Combobox in VIEW MODE not in Edit mode of the form

3. Can you show edit mode form with the formula not working?

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Hello, The images I attached were purely so you could see the drop down values as you had requested in a previous response.

When I'm trying to get it to work, I click my button to add a new record, it opens that form blank so that I can complete the fields. I have an image of the code (New Button) on the new record (+) button.

 

When I select travel as request type at that point, the field I put the visible code on does not appear. I have attached an image of the code (Visible Code). Also, I'm getting an error message as you can see by red ! in the image. I know that although I've selected New Record with the + button, it's just edit mode with blank records, but I presume the code is still OK to say edit as it does?

 

I've also attached images of the form in View Mode and Edit Mode, as well as the view after I select Travel from the drop-down in Edit Mode (Multiple Views). As you can see, the Travel Destination field does not show above the overnight field as expected in any view. 

 

I find the Mode / Display Mode just confusing and knowing when to reference Mode or Display Mode.

 

If I don't get this figured out soon I'm just going to forget it and they will always be visible whether required or not. Power Apps is NOT as intuitive and easy to use for non coders as Microsoft would like to think. I have no issues completing things like this in seconds in other applications, if only I wasn't asked to complete this in Power Apps only.

 

The formula you have stated is Ok. Al

But the  'Request Type' in the formula should be a Dropdown.

Expand the Datacard "Request Type_DataCard" (See Attached) to show the Name of the DatacardValue which represents the Dropdown and use that in the Formula

 

If you are not sure, click on "Request Type_DataCard" , and take a screen shot.

 

So in the formula change it to: DatacardValueName.Selected.Value = "Travel"

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

 

I'm such an idiot!!!  I keep forgetting that a data card has multiple parts. Thank you for your patience!

 

That's working fine now for new entries. Do I just add an additional IF to have it show in View mode if the value is Travel as well? It's not showing in view mode.

 

 

Can you give the current formula that is only working for new enteries

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,888)