- 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 07:02 AM
How are you accessing it?
Boolean has different behavior than other field types.
Are you using getValue() or using dot walk?
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2022 07:08 AM
I guess I could have gave some examples, my bad:
var gr = new GlideRecord("table_name");
gr.addQuery("query");
gr.query();
var boolValue = gr.specific_field;
gs.addInfoMessage("boolValue: " + boolValue);
So the above is how I'm doing it currently. I'm pretty new to SN so I'm still learning.

- 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 07:25 AM
I'm sorry that was a mistake, I edited it the way it should be. I tried it with getValue() and instead of undefined it comes back as null.