cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
martinav
Community Champion
Community Champion

How to trigger a Select() inside a gallery, from outside the gallery.

I need to perform a function inside each gallery row, when triggered by a button outside the gallery.  The function works perfectly when triggered row-by-row inside the gallery.  In the shown example, I'm using a context variable to check the checkbox, then using OnCheck() to Select() the button.  

 

If I check the box directly in the gallery, it works.  If I use the context variable to check the box, OnCheck does not trigger.  Please advise.

 

Here is the scenario and details (Image Updated):

martinav_0-1633981640090.png

1. Select the "Patch All" button.  This sets 'SelectPatch' to true.
2. Default in the 'Option' checkbox is set to 'SelectPatch'.

3. OnCheck() in the 'Option' Checkbox is set to 'Select(Button1)'.  

4. Button1 (labeled "Patch") OnSelect() executes a command.

 

What works:

  • Selecting the check-box in the gallery directly works row-by-row.
  • Selecting the "Patch All" button checks all of the 'Option' Check boxes visually. (but does not execute the button OnSelect().

Please advise!

1 ACCEPTED SOLUTION

Accepted Solutions
v-xiaochen-msft
Community Support
Community Support

Hi @martinav ,

 

Oncheck and Onuncheck will only be triggered when the user clicks the checkbox with the mouse.

So , If you use variables to change the default value of the checkbox, it will not start the oncheck or onuncheck formula.

 

You could use combo box to replace check box execution formula.

For example:

Add a button control and set its Onselect property to:

Set(A,!A)

Add a combo box control and set its Items property to:

Table({Value:1},{Value:2})

 

Set the combo box control's DefaultSelectedItems property to:

If(A=true,{Value:1},A=false,{Value:2})

 

Set the Onchange property to:

Set(B,B+1)

 

Now If you click on the button ,the onchange formula will be executed.

 

In addition, I don't recommend you to do this. Because using multiple patch functions at the same time may cause problems. For example, it may not add records in order.

 

If you want to add/modify records in batches, you should use a combination of forall function and patch function.

 

Best Regards,

Wearsky

View solution in original post

4 REPLIES 4
martinav
Community Champion
Community Champion

Ok, I eliminated the button in this.  Still doesnt work with the "Patch All" button, but works when you pick the check box "on".

 

martinav_0-1633982438714.png

 

 

 

martinav
Community Champion
Community Champion

And again...  Triggering the true value of SelectPatch with an inside gallery pick does not work, except for the line item that is actually selected.

martinav_0-1633982956303.png

 

v-xiaochen-msft
Community Support
Community Support

Hi @martinav ,

 

Oncheck and Onuncheck will only be triggered when the user clicks the checkbox with the mouse.

So , If you use variables to change the default value of the checkbox, it will not start the oncheck or onuncheck formula.

 

You could use combo box to replace check box execution formula.

For example:

Add a button control and set its Onselect property to:

Set(A,!A)

Add a combo box control and set its Items property to:

Table({Value:1},{Value:2})

 

Set the combo box control's DefaultSelectedItems property to:

If(A=true,{Value:1},A=false,{Value:2})

 

Set the Onchange property to:

Set(B,B+1)

 

Now If you click on the button ,the onchange formula will be executed.

 

In addition, I don't recommend you to do this. Because using multiple patch functions at the same time may cause problems. For example, it may not add records in order.

 

If you want to add/modify records in batches, you should use a combination of forall function and patch function.

 

Best Regards,

Wearsky

View solution in original post

martinav
Community Champion
Community Champion

@v-xiaochen-msft 

 

I ended up creating an all new colleciton, and put the formulas in a nested ForAll(collect()) statement.

 

I will try your solution in the next one I do.  This is much easier than what I did.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,399)