cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Yahya
Kudo Kingpin
Kudo Kingpin

Screen Onstart commands

How to do something in PowerApps triggering a Screen Onstart/Onload?

17 REPLIES 17
SvenV
Advocate V
Advocate V

What do you want to start/load? Do you have an example?

Anything, like fill a Button, Run a Flow, anything.

mr-dang
Community Champion
Community Champion

Normally, you can place actions in a Screen's OnVisible property. When you have no objects selected, you can use the property dropdown to select OnVisible and type in whatever actions you want.

 

But if I understand your question, you want to trigger those same actions that you placed in the OnVisible property at other times as well.

 

If that is the case, then I would place your actions into a Toggle.OnCheck property. Upon being checked, the toggle will activate those actions. So the same actions are located in one location and can be triggered in multiple ways: Screen, Button, etc.

 

Next, use a context variable to trigger the toggle.

UpdateContext({variable: true});
UpdateContext({variable: false})

This means, "Make the variable true, then false." Now set Toggle.Default to the name of your context variable. The toggle will be true for a moment, thus activating your OnCheck actions, then it will return to false so that it's ready to trigger again.

Microsoft Employee
@8bitclassroom
mr-dang
Community Champion
Community Champion

Variables are limited to the scope of a screen. So a variable you set on one screen cannot be referenced in another.

 

For advanced triggering, it is possible to place your triggers on one screen and activate it on another, but it is buggy in 2.0.642. It will work in edit mode, but not when the app is opened on the cloud.

 

So instead of the usual context variable:

UpdateContext({variable: true});
UpdateContext({variable: false})

 

You can place the variable in a collection which can be referenced universally:

ClearCollect(variable,{Value: true});
ClearCollect(variable,{Value: false})

 

Set a Toggle's Default property to:

First(variable).Value

This means the Toggle will become true when the first value in the variable collection is true, then it will be false again. The Toggle can then activate any OnCheck actions you have programmed from any screen you want. 

 

Here's an example of advanced triggering with collection:

https://drive.google.com/open?id=0B0iHNZhZKR6YZEl2ejVDbmhyTTA

 

Again, it works in edit mode, but not in cloud.

@v-micsh-msft

Microsoft Employee
@8bitclassroom

But such a feature is basic that should exist and should be straight forward. 

Hi @Yahya,

 

Maybe the following blog would help a little?

UX Patterns: Pre-loader

Which talks about the same way offered by Mr.dang.

Besides, if this is not what you are looking for, then you may consider submit an idea on this through the PowerApps idea forum:

https://powerusers.microsoft.com/t5/PowerApps-Ideas/idb-p/PowerAppsIdeas

 

@mr-dang, so by testing, the variable only works under App edit mode, but not working as expected when running this App?

I will submit feedback once issue confirmed from my side.

Thanks for letting me know.

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Michael,

It's complicated. If you use the collection to store the variable, the variable will work for controls on the same screen.

 

But if you have a control affected by the collected-variable on another screen, then the collected variable will not work as expected in cloud mode. 

 

In Edit mode, everything works. I think collection-variables are the cause of problems on some of my older apps, but I have not had the time to resolve them.

 

@v-micsh-msft

Microsoft Employee
@8bitclassroom
Meneghino
Community Champion
Community Champion

Hi @Yahya

I have read the thread, apologies but I am still not sure of what you are trying to achieve which cannot be achieved with using the screen OnVisible property.

Any concrete example would be appreciated.

Thanks.

hpkeong
Community Champion
Community Champion

Hi

 

OnStart has recently being added in 2.0.650 to make it always being triggers when you start an apps.

OnVisible with formula is when the screen you travel to will trigger an action.

 

TQ

hpkeong

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (2,370)