cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
thomasgarcia83
Level: Powered On

2 If Formula Statements - Not Working

Hello PowerApps Community,

 

By chance would someone be able to point me in the right direction with my challenge. I had a request come in that asked if I could restrict a button based on another button's action. For example, the users at my organization would determine if a review would be necessary on a project. Once they did that via a toggle switch control, that toggle switch would disable the submit form button and enable a notify creator button. That part of the formula statement is working beautifully.

 

However, I cannot get the "submit" button to become visible once the notify button is pressed. Any suggestions would be greatly appreciated. The following formula is in the DisplayMode property for the "Submit" button. 

 

 

If(Toggle1.Value = true, DisplayMode.Disabled, If(NotifyButton.Pressed, DisplayMode.Edit))

 

 

 

Button Function.JPG 

10 REPLIES 10
KOM_4410
Level 8

Re: 2 If Formula Statements - Not Working

HI,

 

Not sure if I fully understand your case but maybe to change the status of the DisplayMode you should create a context variable when clicking on your "notify reviewer" button (eg: UpdateContext({SubmitVisVar:true}) ), so your new formula would be like:

 

If(Toggle1.Value = true, DisplayMode.Disabled, If(SubmitVisVar=true, DisplayMode.Edit))

You'd need to figure it out where else that variable needs to change to false to keep consistency.

 

That's an option...now if clicking on the "Notify reviewer" button finishes the task and you have to reset the form...I would reset the Toggle1 to false and only use that for the DisplayMode property.

 

Hope that helps  

leyburn19
Level 10

Re: 2 If Formula Statements - Not Working

My 20cents worth

 

I would do similar to above but change the visible to be based on the toggle button and removed the review button all together.

 

On the toggle I would set the onchange to be something like:

 

If(Toggle1.Value = true, UpdateContext({VarVis1,true}),UpdateContext({VarVis1,false}))

 

on the visible property to the button set it to be VarVis1

 

Now if the toggel is moved the button will appear or disappear based on it

 

Note on teh OnVisible to the form you alse need to put UpdateContext({VarVis1,true})

 

UpdateContext({VarVis1,false) to make the button invisible

thomasgarcia83
Level: Powered On

Re: 2 If Formula Statements - Not Working

Thank you both for the replies. I will try both out. I started thinking about using a variable as well so at least I feel better internally that 2 minds are thinking similar things, haha!

 

I tried to explain the challenges with this functionality to all users but they would like something like this. What makes it more challenging, is some projects will not require a review which is why the submit button has to stay. They would like to click on an action which allows them to fill in some detail and then force them to select the notify reviewer button and then once they perform that action the submit button enables allow them to pass the record update on to our database.

 

I'll try the options out and see if the result is acceptable. I will keep all posted. Thanks for your help!

-Tom

JRaasumaa
Level 10

Re: 2 If Formula Statements - Not Working


@leyburn19 wrote:

My 20cents worth

 

I would do similar to above but change the visible to be based on the toggle button and removed the review button all together.

 

On the toggle I would set the onchange to be something like:

 

If(Toggle1.Value = true, UpdateContext({VarVis1,true}),UpdateContext({VarVis1,false}))

 

on the visible property to the button set it to be VarVis1

 

Now if the toggel is moved the button will appear or disappear based on it

 

Note on teh OnVisible to the form you alse need to put UpdateContext({VarVis1,true})

 

UpdateContext({VarVis1,false) to make the button invisible


This can be simplified to:

 

UpdateContext({VarVis1:!VarVis1})

Using an exclamation before a Boolean variable in PowerApps flips the state for you making it incredibly simple to change a true false on another button.

 

Set Notify Reviewer to the line of code I pasted above.

 

Set the DisplayMode of the Submit button to:

 

If(VarVis1 = true, DisplayMode.Edit, DisplayMode.Disabled)
Super User
Super User

Re: 2 If Formula Statements - Not Working

One tweak to what @JRaasumaa wrote:

 

If(VarVis1, DisplayMode.Edit, DisplayMode.Disabled)

 

VarVis1 evaluates to true or false so you don't have to check if it = true

 

I will also add a bonus. You don't have to put an If inside of an If. This more advanced syntax and hiding View problems are both covered in one video. 

PowerApps If Statement

 

Hope it helps

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training
thomasgarcia83
Level: Powered On

Re: 2 If Formula Statements - Not Working

@JRaasumaa,

 

Your proposal gets me about 50% there. Though the challenge is as follows:

 

  1. If user determines no review is required, then they do not move toggle and submit button stays visible and no notify button displays (I have this part working).
  2. If user determines review is necessary, the user will select the toggle to engage a text field for email (text field become editable).
  3. Once the toggle is switched on, the notify button becomes active (appears) and the submit button becomes disabled.
  4. User will select notify button which launches an email flow and once the notify button is pressed the submit button now becomes usable (this is the part I cannot get working).
  5. If user decides review is not required, and flips switch, everything goes back to normal as stated in #1.

** I cannot remove the submit button all together, it has to stay as part of the app functionality. The users in my org want it there so they can first notify the reviewer then update the project details via the submit button.

 

@JRaasumaa, your solution has got me the closest to acceptable functionality and I appreciate everyone's feedback. If anybody has any additional formula modifications I would be more than happy to try to reach the goal.

 

I will revisit this formula tomorrow for more in depth testing.

 

Thanks all,

-Tom

thomasgarcia83
Level: Powered On

Re: 2 If Formula Statements - Not Working

@Shanescows,

 

Ahh! I feel star struck, haha! I've learned alot from your videos in the past Shane, how cool of you to respond to my post out of the tons out there, lol!

 

Alright, regathering myself. I sat myself down yesterday and watched your video. I changed a few things based on the tips and tricks you talked about but as I stated in JRaasumaa's reply, I'm still not there.

 

I'll post some scree shots and formula statments later today for feedback.

 

Thanks so much for your post Shane, made my day!

-Tom

Super User
Super User

Re: 2 If Formula Statements - Not Working

Glad my videos are helpful. Smiley Happy Hopefully I can be helpful here also. 

 

In item #4 above. Why not have the OnSelect for the Notify Button launch your flow then set a variable and then enable the button. 

 

YourFlow.Run(stuff you passed); UpdateContext({VarVis1:!VarVis1})

 

Or something close to that. 

 

Did you see my video on PowerApps Flow Tutorial? In the video, I do things differently but make my button at the end visible only after my Flow has done its magic.

 

 

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training
Highlighted
cyarbrough
Level: Powered On

Re: 2 If Formula Statements - Not Working

@thomasgarcia83

 

maybe i'm missing something, but why not just have the submit button run the notify formula/flow plus update the record if the toggle is enabled, and only update the record if the toggle is disabled? are your users insisting that there be two separate buttons?

 

example:

SubmitButton.OnSelect: If(Toggle1.Value=true, [notify formula];[record update formula], [record update formula])

or

SubmitButton.OnSelect: If(Toggle1.Value=true, [notify formula]);
[record update formula]

Helpful resources

Announcements
SecondImage

Join our Live PowerApps Webinar

Tomorrow, September 24st at 10am PDT

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

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

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Users Online
Currently online: 323 members 5,129 guests
Please welcome our newest community members: