cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mart11
Helper I
Helper I

How to use form inputs in a custom component?

Hi everyone! 

 

I have a button as a custom component which has some custom behavioral functions. I am then importing the custom component onto my screen where I have a form. On the custom component button's onSelect(), I would like to pass the form inputs so that the calculations can be performed using these inputs. Is this possible, or is there some other way of using the form inputs in the custom component's onSelect() function? 

 

mart11_0-1659429082679.png

In the above screenshot, the form fields are in the screen, and the Calculate button is a component, which has its onSelect and other behavior functions defined within the components section. How can I use the data input by the user within a behavior function? 

 

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions

Oh I see, sorry I did not fully address your concern.

 

You can add a Record type input argument, then use Form4.Updates as the value for that component argument from your screen.

 

Component input argument:

metsshan_0-1659445909034.png

Component properties from my screen:

metsshan_1-1659446015884.png

Now my button can reference the values from the Form, for example:

Notify(Parent.FormValues.Title)

metsshan_2-1659446104888.png

 

View solution in original post

7 REPLIES 7
metsshan
Solution Sage
Solution Sage

Do you actually ever want to Submit the Form, or just pass the values to the component for processing?

To be honest, no I don't need to submit the form. I just need to validate the form before passing the values to the component (ensuring that all fields are not empty)

All good, then you can use the Form.Updates property:

metsshan_0-1659444418985.png

You can get all values:

Set(FormValues, Form1.Updates)

Or specific values:

 Set(FormValues, First(ShowColumns(Table(Form1.Updates),"Title","Manager","Amount","Active","Status")))

 

mart11
Helper I
Helper I

But I do not have access to Form1 from the components screen (in my case it is Form4). 

 

This is what I am referring to when I say components screen.

mart11_0-1659445148831.png

 

I am calling the below code in the Button10 onSelect() function, Button10 being the custom component. 

mart11_0-1659444949025.png

 

Oh I see, sorry I did not fully address your concern.

 

You can add a Record type input argument, then use Form4.Updates as the value for that component argument from your screen.

 

Component input argument:

metsshan_0-1659445909034.png

Component properties from my screen:

metsshan_1-1659446015884.png

Now my button can reference the values from the Form, for example:

Notify(Parent.FormValues.Title)

metsshan_2-1659446104888.png

 

Perfect, worked like a charm. Thanks for your help! 

How would I perform form validation on this? I would like to make sure that the fields are populated and not left blank (and obviously inform the user if a field has been left blank). 

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Top Kudoed Authors
Users online (1,556)