cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
indhaa
Post Patron
Post Patron

Toggle Control cannot uncheck

Hi

 

So i have my form working last night but today when i did the testing again having some issue.

Do powerapps code give different results on different time. What is the best way to know your code is ok, open the app again after each change? My other forms also have the same issue when i checked again , it is really frustrating when this happens.  

 

Anyway I replaced my text datacard as a toggle and in the toggle default property i kept the below code. But now I'm unable to uncheck during edit mode, there was no issue last night. What i'm trying to achieve is when opening the form the toggle to be checked if SP list column is true and vice versa and user to be able to uncheck in edit mode if they want it. 

 

indhaa_0-1618850458746.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User III
Super User III

@indhaa 

Yes, so you are resetting things from the OnUncheck action that are causing your Toggle to reset to default also.  And, on a New record, the ThisItem.ToggleRequired value will not be True...only on an existing.

You are overrunning the resets and this is causing your issue.

 

Consider the following instead of trying to use any Onxxx Actions.

Set the Visible property of your toggle to:

   TypeOfAccountRadio.Selected.Value = "User Account"

 

Set the Reset property of the TextInput to:

   !YourToggle.Value

 

Set the Default property of the Toggle to:

   Coalesce(Parent.Default, "No")="Yes"

 

The Default property of the datacard with the toggle should be:

   ThisItem.ToggleRequired

 

Then get rid of all the other action formulas and variables and this should give you what you are looking for.

 

Variables!!  This is USUALLY why an app works fine, then saved closed and then opened again it doesn't work.  Once a variable is set, it is very confusing to see that all is working based on that, but what happens when it is NOT set?  This usually only happens once you open the app again.  So, if you have not specifically added things like Coalesce or other checking to determine when the variable is empty, then you will see these type of things.

Always best to work with PowerApps the way it is intended and simply reference what you need from what you already have in your controls and leave the variables behind.

 

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

View solution in original post

14 REPLIES 14
RandyHayes
Super User III
Super User III

@indhaa 

What else have you changed on that toggle - like perhaps any OnSelect or OnCheck or any other action?

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

Hi

 

I'm using the same form for Edit, New and View. I'm having the issue only on Edit mode.

In the toggle OnUncheck property it is defined as below

indhaa_0-1618852410403.png

 For other properties below the value is false

indhaa_1-1618852557313.png

 

RandyHayes
Super User III
Super User III

@indhaa 

So you're stating that only in Edit mode, if the toggle is on and you try to change it to off, it immediately reverts back to on?

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

Yes.

 

If the value on my SP list is true, the toggle is true and I'm unable to check/uncheck it. It goes back to default when I try to uncheck it. But if the value on my SP list is false, I'm able to check / uncheck the toggle. 

 

RandyHayes
Super User III
Super User III

@indhaa 

There is not reason for that happening unless you have some other action on some other control that is resetting your form.

Let me know the following:

- What is the Reset property of the toggle?

- If you take the updatecontext stuff out of your OnUncheck, does the problem go away?  If so, then what is that variable being used for?

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

So In New form mode it is working correctly like this.

 

So the toggle will show if Type of Account is 'User Account'. If onchange of this datacard the toggle will reset. 

If toggle is on, the local email datacard will show and it will reset if any change to the toggle or Type of account datacard. I'm using the same variable in the Reset Property for both datacard.  Also can you let me know why it was working before last night, do i need to close the app before testing ? 

 

indhaa_0-1618854642664.png

 

indhaa_1-1618855104006.png

 

 

RandyHayes
Super User III
Super User III

@indhaa 

Yes, so you are resetting things from the OnUncheck action that are causing your Toggle to reset to default also.  And, on a New record, the ThisItem.ToggleRequired value will not be True...only on an existing.

You are overrunning the resets and this is causing your issue.

 

Consider the following instead of trying to use any Onxxx Actions.

Set the Visible property of your toggle to:

   TypeOfAccountRadio.Selected.Value = "User Account"

 

Set the Reset property of the TextInput to:

   !YourToggle.Value

 

Set the Default property of the Toggle to:

   Coalesce(Parent.Default, "No")="Yes"

 

The Default property of the datacard with the toggle should be:

   ThisItem.ToggleRequired

 

Then get rid of all the other action formulas and variables and this should give you what you are looking for.

 

Variables!!  This is USUALLY why an app works fine, then saved closed and then opened again it doesn't work.  Once a variable is set, it is very confusing to see that all is working based on that, but what happens when it is NOT set?  This usually only happens once you open the app again.  So, if you have not specifically added things like Coalesce or other checking to determine when the variable is empty, then you will see these type of things.

Always best to work with PowerApps the way it is intended and simply reference what you need from what you already have in your controls and leave the variables behind.

 

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

View solution in original post

Hi,

 

Can you tell me what the No and Yes refers to Coalesce(Parent.Default, "No")="Yes".

In the SP List the column value is true and false for the Toggle DataCard.

So when I did as above the toggle does not get Checked when the value in the SPList is true, meaning local email field is not showing even if not blank. It is also not showing this field in Form view mode too even if data exist for the field. Previously if SP List column is false, it will be unchecked meaning no data in the email field too so no need to show. 

 

Hi Randy,

 

Can i get some help in making the toggle to be true if the SP List value is true and vice versa in edit / view mode.

Previously in the default i have this code If(ThisItem.ToggleRequired="true",true,false). 

 

I have not been able to correct this with your formulae Coalesce(Parent.Default, "No")="Yes". 

 

 

 

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (69,081)