- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2022 07:00 AM
I'm trying to write a script that uses if statements to determine an action depending on the value of a bool. If true it does one thing, if false another. I can see in the XML that the field has a true or false value, but when I try to display that value it's just showing it as undefined. Any help would be appreciated.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2022 07:15 AM
This is very generic statement with no specific details:
Issues with your script is you are getting gliderecord reference in gr variable but you are using thresholdsGR object in next line which is incorrect.
You have to keep using gr in subsequent queries
But you can try something as below for your script:
var gr = new GlideRecord("table_name");
gr.addQuery("query");
gr.query();
if(gr.next()){
var boolValue = gr.specific_field;
gs.addInfoMessage("boolValue: " + boolValue);
}
Feel free to mark correct, If I answered your query.
Will be helpful for future visitors looking for similar questions 🙂
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2022 08:02 AM
For boolean it is a special case, if you want to use getValue, you will need to type cast it into boolean as below:
var boolValue = Boolean(gr.getValue("field_name")); // will return true or false
Feel free to mark correct, If I answered your query.
Will be helpful for future visitors looking for similar questions 🙂
Aman Kumar