Checkboxes in Assets why the inconsistency as vars

I was hoping to get an explanation. Or maybe I just don’t know what I’m doing…

If we have a checkbox for a custom field, i would expect the value to be a true/false, 0/1. However, at least in PowerShell, the checkboxes are received as a string “yes” or “no”. This can be confirmed by doing a Write-Output $passedvar.GetType(). However, when using Set-Asset-Field they need to be set as 0/1, or $true/$false (both work). Using “yes” and “no” does not.

Up to now, i’ve had to make a handler to convert the yes and no to boolean for each of the checkbox fields we use, but feel this is not “clean”…

I assume its because what does the check mark really mean at the end of the day? Yes (0) or No (1) or Yes (1) or No (0) depending on the prompt. In this case, its just easier to return Yes or No and have you do at will with the vales, but the API it self requires true/false to relate the information.

As most things, you will need a Boolean converter. While a bit confusing/messy/not clean, its pretty normal to have a function at hand for this. Even python wrote in the yes, y, and n, no as it was pretty common to come across it.

I am not saying they couldn’t fix this behavior - I am just saying its there and its not really unusual to come across it. At the end of the day, someone will have to write that function to make it happen.

Travis, perhaps it’s “easier” for those without any experience programming, but as far back as i can remember(30+ years of programming), false has always been 0.

If you think other wise, ok, but as my 30+ told me its not the same. False is a variable that is in your global variable list that states false = 0. False is just a name space used to link back to 0. Aka you can change what False returns if you know how to do it. Anyways, that aside, you mention Yes and No so that is what I went off. The whole idea still stands - Someone will have to make the function that converts between the two and it doesnt return false and true. Depending on your prompt it could have a different meaning on the value you want to see.

As I said before, if you want to see a different behavior out of it I totally understand. I am just saying because of the way it works/idea it could be given any prompt and that prompt might have a different meaning in what you are looking for/want to see.

I dont have a good example this morning, but think about it in a way of two different UIs talking and you just calling a function to set it for False and True and another call to get said data from.