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

Create a Button Component that has a property for OnSelect

I am working on an app and have been implementing the new Components feature. I am trying to create a button Component that will allow me to control the look of the button and allow me to modify the OnSelect property of the button control with a 'created property' in the Custome Component, but it is not working. I get a formule error. 

 

Capture1.PNG

Does anyone have any thoughts on how to make this work. maybe I have the wrong data type selected. I have text select at the moment but I have tried others.

1 ACCEPTED SOLUTION

Accepted Solutions

@Patch 

Not at this time...PLEASE vote for it here
It would REALLY make Components shine.  Because I believe a lot of people will be trying to make components of "common screen elements" and often, common screen elements will be Menus, PopUp boxes, and other items that NEED an OnSelect or other definable Action.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

10 REPLIES 10
RandyHayes
Super User III
Super User III

@Patch 

What property is this in?  Your picture cut off the left side to see.  But it is basically saying that you are putting a statement where it shouldn't be.  If you are doing this in an OnSelect or some other action, it should be fine.  If you are doing this on any other property, you can't use a Set function.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Patch
Frequent Visitor

@RandyHayes ,
I created a Component called 'BtnLrg', in it I created a custom property called 'Action' with a data type of 'Text'. I then added a button control to the component and in the 'OnSelect' properter I enter the sytax 'BtnLrg.Action'.  

 

BtnLrg.Action

Then when the component is added to the screen; I set the 'Action' property to 'Set(VarTestFilter,true);Set(VarInspSelectDisable,DisplayMode.Disabled)'

Set(VarTestFilter,true);Set(VarInspSelectDisable,DisplayMode.Disabled)

and that is when I get the error. I think I am misunderstanding something or just missing something.

@Patch 

Right, so in this case you are trying to do a Set in a text property...which is not allowed or valid.

There is no concept currently of "raising actions" from your components.

You would need to wire it up differently - in my case I used a toggle on the screen the component was embedded in to simulate the Action being raised.  But it was less than ideal and really broke the "portability" concept of the component.

Incidentally, I have an Idea in the idea forum for exactly this feature.  Please check it out and Vote on it.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Echoing @RandyHayes, you can't place actions where they would not belong.

 

Components do not have a custom property for behaviors like OnSelect today, but you can still change the behaviors of controls within the component to do the actions you want.

@Mr-Dang-MSFT

 

So it is not possible to set up a component that is a button, or an icon, and have the 'OnSelect' action be in or comprised of a custom property?

@Patch 

Not at this time...PLEASE vote for it here
It would REALLY make Components shine.  Because I believe a lot of people will be trying to make components of "common screen elements" and often, common screen elements will be Menus, PopUp boxes, and other items that NEED an OnSelect or other definable Action.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

@Patch 

Right...because you are trying to do a behavior statement in a text field.  You can't do that!

There is no current way to create an Action on a Component.  You can handle actions within the component, but the component cannot interact with items outside of the component.  Your component can change properties within it (output parameters),  and you can set properties from outside it (input parameters), but you do not currently have an Action parameter.  So there is no way for it to "raise" an action where you could put a behavior formula like you have.

Again...vote for this in the ideas forum.

This would be the only way you could do that.  Otherwise, you have to do some seriously clunky methods inside of your hosting screen to "monitor" the values of the parameters and act on them if they change - sounds easy enough, but it's a nightmare and, at the end of the day, it would have been easier to just maintain the "component" as separate controls rather than make a component.

Go vote!!

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
CW
Post Patron
Post Patron

So it's currently January 2021. This is still not available????????????????? Oh I forgot they had to clean up connections to Trello. 

mdevaney
Super User III
Super User III

@RandyHayes @Patch 
Good news Randy, Power Apps canvas components now have behavior type properties which enable the use or OnSelect, OnChange and more!  You can check out how I got it working in the article below.

Link to Article:
https://matthewdevaney.com/power-apps-component-with-an-onselect-property/

 

powerapps-componentonselect-1.gif

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

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.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,274)