function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Bill_GBill_G 

AJAX and Boolean issue

I know this is probably a very simple thing, but I am stuck.

I am returning a custom checkbox field using AJAX (through SControl). I am then trying to do a if statement (if true, then...)

Here is that part of the code.

var CUSTOMFIELD = queryresult.get("customfield");
if (CUSTOMFIELD == true)
{
"CUSTOMFIELD is True"
};


I have tried

== true
== "true"
== 1


None seem to work. If I am getting the result, what value can I use? I put in an alert and the value returned says true.

Thanks!

Message Edited by Bill_G on 01-24-2006 11:05 AM

gsickalgsickal
Use the Boolean constructor, something like this:
 
var isReconciled = new Boolean(contractStatus__c == "Reconciled");
if (isReconciled == true) {
       ... do something
} else {
      do something else
}
 
so your code would now look like this:
 
var CUSTOMFIELD = new Boolean(queryresult.get("customfield"));
if (CUSTOMFIELD == true)
{
"CUSTOMFIELD is True"
};
Bill_GBill_G
Perfect! Thank you. I knew it was something simple.