cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
andreuares
Level: Powered On

Toggle control can't OnUncheck

Hi,

 

I have a problem with the toggle control OnCheck and OnUncheck, OnCheck works fine, but with OnUncheck when I try to patch a sharepoint list colum from true to false, it will auto return to true again.

 

This is my app, I use a gallery to filter items, when I check it puts 'estado_sincro_test' to true or false with UnCheck. 

App.JPG

With Uncheck it works great, I have this monitor behaviour, it patch and the getrows to update.

check.JPG

But when the item is true and try to uncheck to false, it does it, but some miliseconds after, it will patch to true again:

uncheck.JPG

 

I can't find the error.

 

Thanks for your support!

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Toggle control can't OnUncheck

@andreuares 

Please remove any code from the OnCheck and OnUncheck property. 

 

Then put this code in the OnChange property of your toggle for 'estado_sincro_test'.

Patch(OTs; ThisItem; {'estado_sincro_test': Toggle2_1.Value})

 

Let me know if this works.

 

---
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."

View solution in original post

3 REPLIES 3
Super User
Super User

Re: Toggle control can't OnUncheck

@andreuares 

Please remove any code from the OnCheck and OnUncheck property. 

 

Then put this code in the OnChange property of your toggle for 'estado_sincro_test'.

Patch(OTs; ThisItem; {'estado_sincro_test': Toggle2_1.Value})

 

Let me know if this works.

 

---
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."

View solution in original post

andreuares
Level: Powered On

Re: Toggle control can't OnUncheck

Your solution is working, but you know why the other isn't? Maybe I haven't understand how oncheck and onuncheck works.

 

And now that this works, if I want to toggle between NOK or OK string? This was my first attempt, but as I had this problem I tried to simplify with true/false column and not a string.

I had this code in the Onchange:

If(
   ThisItem.'Estado Sincronismo'="OK";
    Patch(OTs;ThisItem;{'Estado Sincronismo':"NOK"});
    If(
        ThisItem.'Estado Sincronismo'="NOK";
        Patch(OTs;ThisItem;{'Estado Sincronismo':"OK"});
        false
        )
)

And in Default:

If(ThisItem.'Estado Sincronismo'="NOK";false;true)

 but I have similar behavior, from OK to NOK works, but not from OK to NOK gets in a infinite bucle.

Super User
Super User

Re: Toggle control can't OnUncheck

@andreuares 

I don't recommend writing a text string to the datasource using a toggle.  Instead I would suggest you leave it as is and change these properties in the toggle.  Your toggle label will now show as "OK" or "NOK" while maintaining a true or false value in the background.

ShowLabel: true
TrueText: "OK"
FalseText: "NOK"

 

If you need to display "OK" or "NOK" elsewhere in the app (like a label) you can do this but putting this code in the Text property of the control.

 

If(
    Toggle2_1.Value=true,
    Toggle2_1.TrueText,   // displays "OK" text
    Toggle2_1.FalseText   // displays "NOK" text
)

 

---
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
thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Kudoed Authors (Last 30 Days)
Users online (4,160)