cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Toggle automatically switches itself

I'm having a problem where my toggle is unchecking itself automatically. I put a function in the OnCheck and OnUncheck events that is supposed to update two columns in the table, like so:

 

OnCheck:

Patch('PTO Request', LookUp('PTO Request', ID = ThisItem.ID), {Approved_x0020_By:User().FullName, Approved_x0020_Date:Today()})

 

OnUncheck:

Patch('PTO Request', LookUp('PTO Request', ID = ThisItem.ID), {Approved_x0020_By:"", Approved_x0020_Date:0001/1/1})

As soon as I switch the toggle, it switches back. What's going on? How can I fix it? A screenshot with this info is attached.

 

Bonus question: How can I replace the date with a null value? It's being set to 1/1/1969...

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Toggle automatically switches itself

ha ha ha. You are correct. I recreated it. Good news is I think I know why also. The reason is the default value. For me, the default is false, which means make this thing unchecked. 

 

Better news? Here is how you fix it. Make a variable that is true or false and set that variable to the default value. Then update variable based on what they checked or unchecked. 

 

checked.PNG

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training
3 REPLIES 3
Highlighted
Super User
Super User

Re: Toggle automatically switches itself

ha ha ha. You are correct. I recreated it. Good news is I think I know why also. The reason is the default value. For me, the default is false, which means make this thing unchecked. 

 

Better news? Here is how you fix it. Make a variable that is true or false and set that variable to the default value. Then update variable based on what they checked or unchecked. 

 

checked.PNG

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training
Super User
Super User

Re: Toggle automatically switches itself

I am out of time for the bonus question but I think the answer is Blank(). Read this blog post for more details. 

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training
Anonymous
Not applicable

Re: Toggle automatically switches itself

Thank you so much Shane - this did the the trick. Really appreciate you coming in and helping!

 

As for the Blank() for clearing the Date field, I couldn't get it to work; it makes no changes to the Date. But I will look into it more.

 

EDIT: This article answers for Blank() - it doesn't work on Date fields yet. Bummer; I'll have to figure out another way.

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 354 members 5,013 guests
Recent signins:
Please welcome our newest community members: