cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Newbie2019
Level 8

Adding true/false toggle linked to Sharepoint list

Hi,

I have been trying for sometime to add a toggle switch to a detention app which I have created for school.

 

When a student attends a detention, I would like the supervising teacher to be able to toggle true (Yes) and have my sharepoint list then update.

toggle 2.JPG

 

 

I have tried many different ways and have been able to get the sharepoint list to update; however, the toggle switch either flicks back to read false (no) or flicks on and off continually.

 

I am guessing that this has somethign to do with the default value?

 

My sharepoint list is called MIMS, and the column to update is Attendance. 

 

I also need to ability to be able to chnage the toggle at any time as some users may accidently select the wrong student and this would need to reversed (toggled off) without issue.

 

At the moment I am manually going into the sharepoint list and changing this to true, which then updates the gallery.

 

I would appreciate any suggestions. 

 

 

3 ACCEPTED SOLUTIONS

Accepted Solutions
Community Support Team
Community Support Team

Re: Adding true/false toggle linked to Sharepoint list

Hi @Newbie2019 ,

The reason why you met this problem is that you set the toggle's OnChange to the formula that is used to create a new record.

And the yes/no field is set to false by default. After you click the toggle, the toggle will change back to its default value.

 

Since the field's data type is yes/no, you do not need to add a toggle button.

If you use a form to update reord, you just need to add the attendance field in the form.

And this field will display as a toggle as default.922.PNG

Then, just set the submit button's OnSelect to : SubmitForm(Form1).

 

If you are not using a form to update, I suggest you set the submit button's OnSelect:

Patch(tablename,Defaults(tablename),{attdance:toggle1.Value,....,....})   //add a new record
Patch(tablename,the record  that you want to modify,{attdance:toggle1.Value,....,....})   //edit an existing record.

Please replace "the record  that you want to modify" to one spefic record. For example: Gallery1.Selected

 

 

Best regards,

 

 

 

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Dual Super User
Dual Super User

Re: Adding true/false toggle linked to Sharepoint list

Hi @Newbie2019 

 

Can you confirm the default property of the toggle button? It should be:
 
ThisItem.Atten
 
Also, update the expression as:
Patch(MIMS,BrowseGallery1_2.Selected,{Atten:Toggle3.Value});Refresh(MIMS)
 
Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

Newbie2019
Level 8

Re: Adding true/false toggle linked to Sharepoint list

It's working! Thank you so much @yashag2255   and @v-yutliu-msft  for all of your time and help. Cheers

View solution in original post

6 REPLIES 6
Community Support Team
Community Support Team

Re: Adding true/false toggle linked to Sharepoint list

Hi @Newbie2019 ,

Do you want to update the Attendance column by using a toggle?

Could you tell me the data type of Attendance column?

I assue that it is a Yes/No column.

Try this formula:

Patch(listname,Defaults(listname),{attendance:Toggle1.Value})

Then, you could update the column with toggle's value.

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Newbie2019
Level 8

Re: Adding true/false toggle linked to Sharepoint list

Hi @v-yutliu-msft 

 

I am wanting to update a Yes / no column in sharepoint.

 

I created a new column called Atten and my list is called MIMS

 

I have added a toggle switch (toggle3) and tried adding your formula:

 

Patch(MIMS,Defaults(MIMS),{Atten:Toggle3.Value})

 

When I was in preview mode I slide the toggle to on.

 

As you can see, it then slide back to being off immediately.

 

test 4.JPG

 

It also didn't update the sharepoint list.

 

I was wondering if I should be using something like the solution to this question:

 

https://powerusers.microsoft.com/t5/General-Discussion/Default-Value-on-Toggle/m-p/296872

 

Any ideas would be appreciated.

 

Community Support Team
Community Support Team

Re: Adding true/false toggle linked to Sharepoint list

Hi @Newbie2019 ,

The reason why you met this problem is that you set the toggle's OnChange to the formula that is used to create a new record.

And the yes/no field is set to false by default. After you click the toggle, the toggle will change back to its default value.

 

Since the field's data type is yes/no, you do not need to add a toggle button.

If you use a form to update reord, you just need to add the attendance field in the form.

And this field will display as a toggle as default.922.PNG

Then, just set the submit button's OnSelect to : SubmitForm(Form1).

 

If you are not using a form to update, I suggest you set the submit button's OnSelect:

Patch(tablename,Defaults(tablename),{attdance:toggle1.Value,....,....})   //add a new record
Patch(tablename,the record  that you want to modify,{attdance:toggle1.Value,....,....})   //edit an existing record.

Please replace "the record  that you want to modify" to one spefic record. For example: Gallery1.Selected

 

 

Best regards,

 

 

 

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Newbie2019
Level 8

Re: Adding true/false toggle linked to Sharepoint list

Hi @v-yutliu-msft Thank you so much for your assistance.

 

I have added your suggested formula : 

Patch(tablename,the record  that you want to modify,{attdance:toggle1.Value,....,....})   //edit an existing record.

code 1.JPG 

When I select the toggle, it successfully updates the sharepoint list with a Yes in the column.

 

Thank you for getting me this far.

 

I was wondering how I can get the toggle to stay on. That is, how do I make the toggle mirror what the sharepoint list displays?

 

Code 2.JPG

 

At the moment it reverts back to off.

 

I am guessing that this has something to do with the default setting?

 

Also, after moving the toggle a few times I received this error:

code 3.JPG

 

As many people will have access to toggle on that a student attended a detention, they may make an error and toggle it off and back on again.

 

I need it to be able to do this.

 

I would appreciate any additional suggestions.

 

Thanks.

 

Dual Super User
Dual Super User

Re: Adding true/false toggle linked to Sharepoint list

Hi @Newbie2019 

 

Can you confirm the default property of the toggle button? It should be:
 
ThisItem.Atten
 
Also, update the expression as:
Patch(MIMS,BrowseGallery1_2.Selected,{Atten:Toggle3.Value});Refresh(MIMS)
 
Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

Newbie2019
Level 8

Re: Adding true/false toggle linked to Sharepoint list

It's working! Thank you so much @yashag2255   and @v-yutliu-msft  for all of your time and help. Cheers

View solution in original post

Helpful resources

Announcements
thirdimage

Coming Soon: T-Shirt Design Contest

Keep your eyes open for our upcoming T-shirt design contest!

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

Top Solution Authors
Top Kudoed Authors
Users online (6,327)