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 / Set Checkbox value ret...
Power Apps
Answered

Set Checkbox value return query from database MSSQL

(0) ShareShare
ReportReport
Posted on by 17

Good afternoon,

I have run into a bit of an issue that I've been struggling with for a while now and hope someone can help.

 

I can retrieve the information from the database and put into a collection, but when i compare through an if statement, the value of the "Set(x)" doesn't seem to update the checkbox default field. 

Since MSSQL doesn't have a Boolean option for a datatype, i have tried "tiny-int", Char(10), nvarchar(10) but that doesn't seem to make a difference.  Does anyone have the proper way to do this?  

 

Is there another way a text value can be converted to a Boolean value?

 

this is one thing I have tried:   Set the default value of the checkbox to:

 

Capture.PNG

 

 

Here is another:  On Visible of the page start, the

 

 

 

checkbox default = xA1, 

xDone1 value = true (text value from database)

 

 

 

I have also tried: 

 

 

 

If(First(HistCollection).xDone1 = "true", Set(xA1,true), Set(xA1, false)); 

 

 

 

  the same as below, just broken down more.

For some reason with whatever i do, i can not seem to "Set" the variables.  This is a large program and have done it in many other parts of it, but this one has got me.

 

Capture1.PNG

 

Thank you

Categories:
I have the same question (0)
  • Soundjam Profile Picture
    17 on at

    I have also tried this as well, but still doesn't seem to work

     

    Set(xA1, If(First(HistCollection).xDone1 = "true", true,false ))

     

  • Verified answer
    Soundjam Profile Picture
    17 on at

    I think I've finally found my solution to the problem.

    For testing purposes, I set some of the fields in the database to be nvarchar(10), and some to be char(10) to see what would work best, even tinyInt (i abandoned this one).

     

    However, after the last few hours of going through this and i couldn't figure out why this would not pass through and work 😞

     

    If(First(HistCollection).xDone1 = "false", Set(cBox, true), Set(cBox, false));
    Set(xA1, cBox)

     

    the result would not set cBox to true, whether the result from xDone1 was true or false 

     

    Solution:  The field length in the database was set to 10.

    In reality,,  Len("true") = 4 and Len("false") = 5, but the "true" result I was expecting was a length of 10.  Yip,, the field length in the database, but powerapps was not comparing the text it was including the spaces left over!.. bummer.

     

    So after adding in the Trim function to tear off the extra space... Everything is fine.

     

    Capture5.PNG

     

    Now i just paste the code into the Default field of the Checkbox:

     

    Trim(First(HistCollection).xDone1)

     

    and all is good.  Now i'm off to the races again.

    However, one thing better to do is:  Set the Default of the Checkbox to a variable,, such as xA1 and on the select button that takes me to this screen, set the variable with this:

     

    If(Trim(First(HistCollection).xDone1) = "true", Set(xA1,true), Set(xA1,false))

     

     

    Hope this helps anyone with the same problem

     

  • v-siky-msft Profile Picture
    Microsoft Employee on at

    Hi @Soundjam 

     

    Gald to see you have found the resolution.

    Could you please mark your answer as a solution to help other members find it quickly?

    Sik

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 401 Most Valuable Professional

#2
11manish Profile Picture

11manish 201 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard