cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Super User
Super User

How to Connect ResetForm Action to Cancel Component

@Mr-Dang-MSFT et al.

For some reason I just can't wrap my head around how to connect the action for my Cancel Component. 

Objective:  When cancel is clicked from an edit page, I need to execute a ResetForm and then a Back().  Here's a non-component example:

CancelToday.jpg

So here's the definition of the very simple component.  

Cancel Component.jpg

Originally, I had hoped to execute the Reset and Back from the On Select action of the component by passing in the relevant screen/form, but I discovered form was not a valid data type so I tried passing in screen, but haven't figured out a way to reference the form on the screen within the component.  When that didn't get me where I wanted, I added the Output cancelSelected to pass that knowledge back to the app so I could execute these actions there, but I soon realized that there is no action available for the instantiated component for me to attach the ResetForm and Back to.  I also looked at whether I could somehow attached the actions to the screen itself, but couldn't find a place there it made sense either.

Cancl2.jpg

 

What am I missing?  I know there is some fundamental concept I'm just not getting but after fighting with this off and on for several days, I have gotten nowhere.  Where can I execute the necessary actions in response to the icon on Component_Cancel_1 having been selected?

 

Thanks in advance.

LRVinNC

------------------
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Power Apps
Power Apps

Re: How to Connect ResetForm Action to Cancel Component

Hi @LRVinNC ,

Big idea is a component has a scope for the master instance and instances throughout your app.

 


@LRVinNC wrote:

@Mr-Dang-MSFT et al.

For some reason I just can't wrap my head around how to connect the action for my Cancel Component. 

Objective:  When cancel is clicked from an edit page, I need to execute a ResetForm and then a Back().  Here's a non-component example:

...

Originally, I had hoped to execute the Reset and Back from the On Select action of the component by passing in the relevant screen/form, but I discovered form was not a valid data type so I tried passing in screen, but haven't figured out a way to reference the form on the screen within the component.  When that didn't get me where I wanted, I added the Output cancelSelected to pass that knowledge back to the app so I could execute these actions there, but I soon realized that there is no action available for the instantiated component for me to attach the ResetForm and Back to.  I also looked at whether I could somehow attached the actions to the screen itself, but couldn't find a place there it made sense either.

 


The master instance cannot see controls outside of it by design (this is its scope). You do not want to design a component that would depend on something that would not exist if someone else were to import it.

 

Ex: you make a component rely on the form called EditProject; if someone else were to import this hypothetical component and not have that form control with that exact name, it would break and they would need to hunt for the dependencies. Not a very happy person.

 

This is why for every custom property you create, we slug it with some default placeholders. Then when the component is instantiated, you can wire up its dependencies with the rest of the app.

 

That said, forms are not supported in components today: inserting the form control itself, and its type is not among the custom properties. This is unlike screens which have a placeholder and custom property type (App.ActiveScreen).

 

So how do you make a component trigger ResetForm? Short answer is I'd do that particular action externally from a component today. Long answer is you could use the boolean output property of the component to flip a toggle outside, but what's the point when a button outside the component could do as much 🙂

 

We're working to enable more scenarios like this. As we're in preview, my suggestion is to work within the existing capabilities of components which you can find at the base of this post:

https://powerapps.microsoft.com/blog/components-start-your-journey-with-reusable-controls/

View solution in original post

2 REPLIES 2
Highlighted
Power Apps
Power Apps

Re: How to Connect ResetForm Action to Cancel Component

Hi @LRVinNC ,

Big idea is a component has a scope for the master instance and instances throughout your app.

 


@LRVinNC wrote:

@Mr-Dang-MSFT et al.

For some reason I just can't wrap my head around how to connect the action for my Cancel Component. 

Objective:  When cancel is clicked from an edit page, I need to execute a ResetForm and then a Back().  Here's a non-component example:

...

Originally, I had hoped to execute the Reset and Back from the On Select action of the component by passing in the relevant screen/form, but I discovered form was not a valid data type so I tried passing in screen, but haven't figured out a way to reference the form on the screen within the component.  When that didn't get me where I wanted, I added the Output cancelSelected to pass that knowledge back to the app so I could execute these actions there, but I soon realized that there is no action available for the instantiated component for me to attach the ResetForm and Back to.  I also looked at whether I could somehow attached the actions to the screen itself, but couldn't find a place there it made sense either.

 


The master instance cannot see controls outside of it by design (this is its scope). You do not want to design a component that would depend on something that would not exist if someone else were to import it.

 

Ex: you make a component rely on the form called EditProject; if someone else were to import this hypothetical component and not have that form control with that exact name, it would break and they would need to hunt for the dependencies. Not a very happy person.

 

This is why for every custom property you create, we slug it with some default placeholders. Then when the component is instantiated, you can wire up its dependencies with the rest of the app.

 

That said, forms are not supported in components today: inserting the form control itself, and its type is not among the custom properties. This is unlike screens which have a placeholder and custom property type (App.ActiveScreen).

 

So how do you make a component trigger ResetForm? Short answer is I'd do that particular action externally from a component today. Long answer is you could use the boolean output property of the component to flip a toggle outside, but what's the point when a button outside the component could do as much 🙂

 

We're working to enable more scenarios like this. As we're in preview, my suggestion is to work within the existing capabilities of components which you can find at the base of this post:

https://powerapps.microsoft.com/blog/components-start-your-journey-with-reusable-controls/

View solution in original post

Highlighted
Super User
Super User

Re: How to Connect ResetForm Action to Cancel Component

Thanks @Mr-Dang-MSFT.  Thanks Brian.  I feel MUCH better now knowing I really wasn't missing something and there simply isn't a way to do this specific action right now. I've created several other components that all work great. 

LRVinNC

------------------
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

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