This project has moved and is read-only. For the latest updates, please go here.

SPBooleanField - Cannot set value always setting to "True"

May 10, 2011 at 4:43 PM

I have been testing this nice utility (Thanks for the hard work btw!) without any issues until today. I was testing a script using some boolean fields and noticed that it did not matter what value I used in the .SetValue(string) method for my boolean field it was always being set to True (Checked on the form). The only way I was able to get the boolean field to be set to False (Unchecked on the form) was to use .SetValue("") (Empty String).

I tried SetValue("False"), SetValue("false"), SetValue("No"), SetValue("no"), SetValue("0") and all of them set the value to True (Checked on the form).

Maybe I am using this incorrectly, my code is:

var spField = SPUtility.GetSPField('CTPAT Certified');
if (spField != null) 
May 10, 2011 at 7:58 PM

Glad you are finding it useful! Try using it without the quotes, for example:

// Set the field to "yes" (checked)
// Set the field to "no" (not checked)

May 10, 2011 at 10:15 PM

Thanks for the quick response, that works like a charm.

Also, just in case anyone else tries, the values must be lowercase (True/False will fail).