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

How to Click on a button on a different form

How does one Click on a button on a different form?

 

Select(Button1) works if Button1 is on the current form.

 

But what if Button1 exists on another form ?


Can this Button Click happen in the background, or must the form appear after it it has been navigated to ?

3 ACCEPTED SOLUTIONS

Accepted Solutions
Super User
Super User

Re: How to Click on a button on a different form

@vsslasd 

Select will only impact controls on the current screen.

 

If you're trying to kick off a formula, you might consider using a Toggle (on any screen).

Create a toggle.  Put your formula in the OnCheck of the toggle and add one statement at the end of your formula.  Something like this : Set(runRoutine, false)

Set the Default of the toggle to runRoutine (or whatever you call the variable above)

Then, in places where you wanted to "select the button" instead, put a Set(runRoutine, true)

That will toggle the toggle to true and will cause the OnCheck formula to execute.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
PowerApps Staff Mr-Dang-MSFT
PowerApps Staff

Re: How to Click on a button on a different form

Controls on other screens will not trigger their actions unless the active screen has a dependency on the control from the other screen. The control must be referenced somewhere. This is by design.

 

Here's the pattern I use:

 

Screen5

 

ToggleButton.Default
runPatch
ToggleButton.OnCheck
Patch(...); Set(runPatch, false)

 

 

 

Screen2

 

Button.OnSelect:
Set(runPatch, true)

 

So Screen5 has a dependency on a variable from Screen2. Screen2 just needs a dependency on the toggle. Somewhere on Screen2, make a reference to: ToggleButton.Value. This could be in a label.

 

 

Super User
Super User

Re: How to Click on a button on a different form

@Mr-Dang-MSFT 

That is definitely explaining why I'm not hearing cries from any of my app users.  Since I typically will put most all formulas of redundant need or of any substantial complexity on a dedicated screen...and then use a toggle to "call" them, I am pretty sure that most apps have some dependencies.

But, I can see getting into trouble with this - only because trouble lurks when you can do one thing in design and it doesn't work in play. Smiley Frustrated

 

As for @vsslasd , I suppose in this case, if a dependent control is placed on the "calling" screen (even if not visible), that would solve the issue.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
26 REPLIES 26
Super User
Super User

Re: How to Click on a button on a different form

@vsslasd 

Select will only impact controls on the current screen.

 

If you're trying to kick off a formula, you might consider using a Toggle (on any screen).

Create a toggle.  Put your formula in the OnCheck of the toggle and add one statement at the end of your formula.  Something like this : Set(runRoutine, false)

Set the Default of the toggle to runRoutine (or whatever you call the variable above)

Then, in places where you wanted to "select the button" instead, put a Set(runRoutine, true)

That will toggle the toggle to true and will cause the OnCheck formula to execute.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
vsslasd
Level: Powered On

Re: How to Click on a button on a different form

Thank you. That was most helpful.

vsslasd
Level: Powered On

Re: How to Click on a button on a different form

This seems to work great in the Developer Studio version, but does not work in the Desktop Player version, nor on the Mobile Version.

 

Are there any special configuration settings required for these other two environments ?

vsslasd
Level: Powered On

Re: How to Click on a button on a different form

I tried this:

It totally works in the Studio Developer Mode.

But it does not work in the Windows Desktop Play Mode, nor the Mobile Phone App. It starts correctly, but never does the patch or end runPatch,false.

 

Screen2

Button | Onselect

Set(runPatch, true);

 

Screen 5

ToggleButton | OnCheck

 

Patch Statement Here..

 

Set(runPatch, false);

 

 

Any thoughts ? Thank you.

Super User
Super User

Re: How to Click on a button on a different form

@vsslasd 

Hmm...this technique works well for me in many many apps.

 

I would suspect there is an issue with your Patch formula.  If it never sets the runPatch to false, then it is hitting an error before it gets to that. 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
vsslasd
Level: Powered On

Re: How to Click on a button on a different form

Yes, I hear  you. Thank you.
But the issue is that it is successful in the Developer Run Mode, just not the Player Mode. I don't see how the code would would impact that.

I will make some simple commands that I can test.

 

Highlighted
Super User
Super User

Re: How to Click on a button on a different form

@vsslasd 

Yes, so again, the issue is most likely the formula is failing in the player.  Not so much the toggle concept and how to kick that off.  

If there is an error in your patching in that toggle (play time vs design time), that would be what I would focus on.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
vsslasd
Level: Powered On

Re: How to Click on a button on a different form

I made this very simple, so I could see what was happening:

 

Created a PatchScreen.

Added a Toggle to the Screen with a default value: runRoutine

 

On the OnCheck property:

Set(runRoutine, false);

 

 

On my main screen, created a button

On the OnSelect property:

Set(runRoutine, true)

 

I have a rectangle whose Visible property is set to runRoutine.

 

I click the button in the Developer Runtime mode.

 

The Pop Up appears very quickly and disappears, as expected.

 

On the Mobile Phone App and the Desktop Player App.

The Popup window appears but does not ever disappear, and it should.

 

The code is very simple. That's all there is to it.

 

It works correctly in the Developer Runtime, but not the others, unfortunately.

 

 

 

vsslasd
Level: Powered On

Re: How to Click on a button on a different form

So I'm wondering if there is something in the "App Settings" configuration that needs to be set.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

Follow PowerApps on Twitter

Stay Up-to-Date by following PowerApps on Twitter

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!

Users Online
Currently online: 43 members 4,122 guests
Recent signins:
Please welcome our newest community members: