cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gjme
Frequent Visitor

Problems using a variable to disable / enable a button

Hi All,

I'm building an app to control a number of Power Automate Flows that perform various functions to SharePoint.

I am using the "respond to PowerApps" at the end fo the flows to return messages and status of the functions performed.

 

One flow in particular (which checks for the existance of a SharePoint site) responds with "siteexists" = "true/false" which is captured in the power app variable FlowResponse.siteexists.

 

I can see that the value for FlowResponse.siteexists is being correctly updated (I've set a label to display the value).

 

Where I run into problems is that if the site exists, I need to disable the button that kicks off the flow to "Create a Site".

 

I've tried to achieve this by changing the DisplayMode of the "Create a Site" button like this:

 

If(FlowResponse.siteexists = "true", DisplayMode.Disabled, DisplayMode.Edit)

 

The button however does not change display mode even though I can see the value of FlowResponse.siteexists is changing.

 

Any help would be greatly appreciated, thanks

1 ACCEPTED SOLUTION

Accepted Solutions
gjme
Frequent Visitor

Thanks @JP_Verolme and @NandiniBhagya20 for your responses. 

I kept trying to find a way to make it work...  I did try the boolean suggestion, it didn't work at first, so I went back to using a text value in the response from power automate and eventually (re-typing/changing it for the 20th time) I used "True" instead of "true" in the If statement... problem solved... who knew it was case sensitive!  It works perfectly now  

 

This is the working statement:

 

If(FlowResponse.siteexists = "True", DisplayMode.Disabled, DisplayMode.Edit)

View solution in original post

7 REPLIES 7
NandiniBhagya20
Solution Sage
Solution Sage

On App Start property you can call the flow which you have created - 

Set(varsiteexists, FlowResponse.Run().siteexists)

Then in DisplayMode property of button control you can use -

If(varsiteexists = "true" || varsiteexists, DisplayMode.Disabled, DisplayMode.Edit)


Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.

JP_Verolme
Resolver I
Resolver I

Hi @gjme ,
Could you give this a try?

If(FlowResponse.siteexists, DisplayMode.Disabled, DisplayMode.Edit)

I'm not sure, but if you want to use 'true' als a boolean value, you need to use it without the quotes, because then it is seen as a text value.
Furthermore, we can remove the equation part, because the 'If' statement checks wether a statement is true. 
Because 'FlowResponse.siteexists' has the value 'true' (or false) the output is already a boolean value, so there is no need to use '= true'. 
I hope this is helpful for you. If so, please click on the Thumbs Up below and Accept it as the solution, so this could be helpful to others with the same problem.
Kind regards, Jan-Pieter

gjme
Frequent Visitor

Thanks @JP_Verolme and @NandiniBhagya20 for your responses. 

I kept trying to find a way to make it work...  I did try the boolean suggestion, it didn't work at first, so I went back to using a text value in the response from power automate and eventually (re-typing/changing it for the 20th time) I used "True" instead of "true" in the If statement... problem solved... who knew it was case sensitive!  It works perfectly now  

 

This is the working statement:

 

If(FlowResponse.siteexists = "True", DisplayMode.Disabled, DisplayMode.Edit)

SebS
Memorable Member
Memorable Member

@JP_Verolme 

 

how you trigger the flow in first place?

Do you have a button what trigger it or it's trigger from Power Automate trigger?


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

I've got several buttons that each start a different flow (different use cases)..but I needed to be able to turn the buttons on / off based on the results of other flows.  For example, CreateDocumentLibrary needed to be "off" until the CheckSiteExists flow had returned a positive result.

 

In the OnSelect property of the button I have the following generic statement:

 

Set(varFlowResponse, FlowName.Run(vars...))

SebS
Memorable Member
Memorable Member

 

Change OnSelect of the button to

 

 

 

 

IF(Set(varFlowResponse, FlowName.Run(vars...).siteexists)= "True",Set(varSiteE, true),Set(varSiteE, false))

Or try this one

Set(varFlowResponse, FlowName.Run(vars...);
If(varFlowResponse.siteexists = "True",Set(varSiteE, true),Set(varSiteE, false))

 

 

 

 

To all buttons place 

 

 

 

 

IF(varSiteE, DisplayMode.Edit,DisplayMode.Disabled)

 

 

 

 

on Screen OnVisible property place 

 

 

 

 

Set(varSiteE, false)

 

 

 


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

@gjme 

 

Check the above I edit it one of above in OnSelect should work


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

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,086)