web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Collect Toggle Switch ...
Power Apps
Answered

Collect Toggle Switch Value write to dataverse Yes/No

(0) ShareShare
ReportReport
Posted on by 14

As subject line states, I have a canvas app with a toggle switch (Toggle1) that I want to Collect() with a button and write the value to a dataverse table column (Col1) which is of type Yes/No

 

In the button 'OnSelect' field I enter:

 

`Collect(table, {Col1:Toggle1.Value})`

 

This returns the error:

 

"The function Collect has some invalid arguments. Incompatible type. The Col1 column in the data source  you're updating expects 'OptionSetValue' and you're using a 'Boolean' type. "

 

I've scoured the forums to no avail.

 

Thanks.

 

Categories:
I have the same question (0)
  • Manan-Malhotra Profile Picture
    621 Super User 2024 Season 1 on at

    In the button try

    If(Toggle1.Value=true,Collect(table, {Col1:choicename.Yes),Collect(table, {Col1:choicename.No))

     

    Choice name can be found in reference to below image example "aaaaaa" in this case

    MananMalhotra_0-1664812212299.png

     

     

    OR it can be found with reference to below image

    MananMalhotra_1-1664812320210.png

     

    `

  • mikerosoft_user Profile Picture
    14 on at

    mikerosoft_user_0-1664814231367.png

    I'm not entirely sure what you mean by choice names. As in use the label under 'Choices'? Note that the real column name is displayed here instead of alias.

     

    If(Toggle1.Value=true, Collect(table, {wasAnxious:Yes.Yes}),Collect(table, {wasAnxious:No.No}));

     This still results in an Error. 

  • Manan-Malhotra Profile Picture
    621 Super User 2024 Season 1 on at
    If(Toggle1.Value=true, Collect(table, {wasAnxious(@table):Yes.Yes}),Collect(table, {wasAnxious(@table):No.No}));

    In your case you will see a   name in this way "wasAnxious(@table)" where  you will get a wasAnxious(@table).yes or wasAnxious(@table).no

    Please follow this syntax after using the following above name

    If(Toggle1.Value=true,Collect(table, {Col1:choicename.Yes),Collect(table, {Col1:choicename.No))

     

  • mikerosoft_user Profile Picture
    14 on at

    I appreciate the help but it's just not working for me (totally new to powerapps). To reproduce the example verbatim:

    my table is called : records

    the column to update: wasAnxious

    toggle switch name: Toggle1

    And the create statement is placed in a button 'OnSelect' field.

     

    I appreciate the help, and will mark as correct answer if I can get it to work. Thanks again.

     

  • jorge.daniel Profile Picture
    1,430 Super User 2024 Season 1 on at

    Hi,

     

    You say you want to collect the value and write it to a dataverse table. Is there a reason not to just write it to the table?

     

    For a new record, try this is your button's OnSelect: Patch(records, Defaults(records), {wasAnxious: 'wasAnxious (MyTables)'.Yes})

     

    To have the value depend on the toggle, you have the solution from @Manan-Malhotra :

     

    If(Toggle1.Value=true, Patch(records, Defaults(records), {wasAnxious: 'wasAnxious (MyTables)'.Yes}), Patch(records, Defaults(records), {wasAnxious: 'wasAnxious (MyTables)'.No}) )

  • Verified answer
    Manan-Malhotra Profile Picture
    621 Super User 2024 Season 1 on at

     

    If(Toggle1.Value=true, Patch(records, Defaults(records), {wasAnxious: 'wasAnxious (MyTables)'.Yes}), Patch(records, Defaults(records), {wasAnxious: 'wasAnxious (MyTables)'.No}) )

     

    @mikerosoft_userplease try the following code as given below

    Hope this works for you

     

    Please Accept as Solution if it solves your question Or just give it a Thumbs Up if it is helpful because this can help others.

    LinkedIn: https://www.linkedin.com/in/manan-malhotra-vfx/

    Want to support me! Buy me a Cup of Coffee?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 385

#2
Vish WR Profile Picture

Vish WR 367

#3
timl Profile Picture

timl 340 Super User 2026 Season 1

Last 30 days Overall leaderboard