cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Button DisplayMode help

Hi all,

Need help (again).  Trying to edit the dislaymode for a button.  If a form's textboxes are empty, I want the displaymode for the button false, otherwise true.  Sound's simple, right?  That's what I thought.  I've tried the below, and none of them work properly.

 

If(IsBlank(combo_SubjectValue.Selected.Title || txt_CourseNumValue.Text || txt_CourseTitleValue.Text || num_CourseCreditValue.Text), DisplayMode.View, DisplayMode.Edit)

 

If(Or(IsBlank(combo_SubjectValue.Selected.Title), txt_CourseNumValue.Text), txt_CourseTitleValue.Text), num_CourseCreditValue.Text)), DisplayMode.View, DisplayMode.Edit)

 

If(IsBlank(combo_SubjectValue.Selected.Title) || IsBlank(txt_CourseNumValue.Text) || IsBlank(txt_CourseTitleValue.Text) || IsBlank(num_CourseCreditValue.Text), DisplayMode.View, DisplayMode.Edit)

 

If(!IsBlank(combo_SubjectValue.Selected.Title && txt_CourseNumValue.Text && txt_CourseTitleValue.Text && num_CourseCreditValue.Text), DisplayMode.Edit, DisplayMode.Disabled)

 

If(Not(IsBlank(combo_SubjectValue.Selected.Title)) && Not(IsBlank(txt_CourseNumValue.Text)) && Not(IsBlank(txt_CourseTitleValue.Text)) && Not(IsBlank(num_CourseCreditValue.Text)), DisplayMode.Edit, DisplayMode.Disabled)

 

 

This is just a few of the iterations I've tried.  AppChecker has no issues with any of these, but the button still will not disable if one of the datacards is empty.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Button DisplayMode help

I got it to work!  After some precise troubleshooting, and some google-ing, I got it.

 

If(IsBlank(num_ApprCreditValue.Text) || IsBlank(txt_ApprNumValue.Text) || IsBlank(txt_ApprTitleValue.Text) || IsEmpty(combo_ApprSubjectValue.SelectedItems.Title), DisplayMode.Disabled, DisplayMode.Edit)

 

I think the combobox was my problem.  

@Pstork1, thank you SO MUCH for your help! 

9 REPLIES 9
Super User
Super User

Re: Button DisplayMode help

I find that trying to directly modify properties at run time seldom works.  Here's a different approach

In the OnChange method of each data card set a variable using a fomula like this:

If(IsBlank(TextInput1.Text),Set(viewmode1,true),Set(viewmode1,false))

Use a different variable for each card

Then in the Button DisplayMode property use a formula like this:

If(viewmode1||viewmode2,DisplayMode.View,DisplayMode.Edit)

 

If the text in the textbox is changed to blank it will set the value of the variable.  The Button will then change its setting based on the value of the variable. In my test if any of the textboxes were blank then the Button was in View mode and OnSelect didn't fire.

 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Re: Button DisplayMode help

@Pstork1

Thanks for the reply!  There are 4 fields that I need to be required before submission.  3 of them are pre-populated with values from a gallery item.  The 4th one is blank by default.  Using the OnChange would work for the blank field, but I don't think it'd work for the pre-populated fields.  Since the user may not alter them.

Super User
Super User

Re: Button DisplayMode help

You said you only wanted to disable the button if the text fields were blank.  The three that are pre-populated won't be blank.  If the user fills in the 4th box, but doesn't change the other three then the button should be in Edit mode. If you fill something into the 4th text box, but delete the text in one of the pre-populated boxes then the button will still be disabled because the onChange will take place when you delete the text in the fourth text box.  The onChange formula needs to be added to each text box. Try it and I believe you will find that it works.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Re: Button DisplayMode help

@Pstork1 

Son of a gun, it works!  I apologize for being a doubting Thomas.  It definitely seems like a more round-about way of doing it.  I really think one of my examples should have been sufficient.

Super User
Super User

Re: Button DisplayMode help

It reflects a common problem in PowerApps.  Most of us are used to building things in procedurally based languages where we can have an action change a property on a control.  PowerApps doesn't work that way since its declarative, not procedural.  So the common workaround is to have the action set a variable and then have the other property change based on the values of the variable. It is a round about way of doing things, but I've used it several times and it works. Glad it worked for you.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Highlighted

Re: Button DisplayMode help

@Pstork1 

I spoke too soon.  I guess when I made the app, I made an extra wrinkle.  I apologize for not being more detailed in my initial post.  The app is an approval app.  To get to the fields I'm working with, the user clicks the approve button, which opens a popup, which has the four fields in it.  When I first put in your solution it worked, until I closed the popup and clicked the approve button again (to get the popup again).  I figured it was because the variables I created weren't initialized.  So I initialized them when the user clicks the approve button (OnSelect).  When the popup appears, the Submit button is disabled (as it should be), but the Submit button doesn't change to Edit unless every field is changed somehow.  This won't work because a user won't necessarily edit the pre-populated.  I am banging my head against the wall because I don't understand why the button control has an issue with setting a displaymode value if certain conditions exist.

Super User
Super User

Re: Button DisplayMode help

Try setting the variable for each control when you initialize the textboxes in the popup.  Then if they change an entry it will react appropriately, but if they don't then the values will be preset before a change takes place.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Re: Button DisplayMode help

I got it to work!  After some precise troubleshooting, and some google-ing, I got it.

 

If(IsBlank(num_ApprCreditValue.Text) || IsBlank(txt_ApprNumValue.Text) || IsBlank(txt_ApprTitleValue.Text) || IsEmpty(combo_ApprSubjectValue.SelectedItems.Title), DisplayMode.Disabled, DisplayMode.Edit)

 

I think the combobox was my problem.  

@Pstork1, thank you SO MUCH for your help! 

Super User
Super User

Re: Button DisplayMode help

Glad you got it working.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, August 21st at 8am PDT

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

SixthImage

Power Summit Australia 2019

August 20-23rd 2019

Users Online
Currently online: 269 members 4,289 guests
Please welcome our newest community members: