- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2023 06:35 AM
Hi All,
Sorry if this is super simple but i'm unable to make this work so hoping someone could help.
I'm trying to exclude false or null values when using the record producer.
We have radio buttons that if not selected it returns a value false which then comes into the ticket.
I've been able to get either null values not showing or false not showing but not both.
Script below where you can see my failing script.
var gr_questions = new GlideRecord('item_option_new');
gr_questions.addQuery('sys_id', 'IN', arr_questionSysIds.toString()); //Single call to the table with all variables we are looking for
gr_questions.orderBy('order'); //Order by the order they are on the catalog item form
gr_questions.query();
var description = "";
while (gr_questions.next()) {
var question = gr_questions.getValue('question_text');
var value = producer[gr_questions.getValue('name')].getDisplayValue();
if (value !== "false" && !null)
{ //only get variables with values
description += question + ": " + value + "\n";
}
I've also tried if ((value !== "false") || (value !== null))
any assistance would be greatly appreciated
Cheers as always
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2023 06:37 AM
Hi @Sam Motley
Try this:
var gr_questions = new GlideRecord('item_option_new');
gr_questions.addQuery('sys_id', 'IN', arr_questionSysIds.toString()); //Single call to the table with all variables we are looking for
gr_questions.orderBy('order'); //Order by the order they are on the catalog item form
gr_questions.query();
var description = "";
while (gr_questions.next()) {
var question = gr_questions.getValue('question_text');
var value = producer[gr_questions.getValue('name')].getDisplayValue();
if (value && value != null && value != '')
{ //only get variables with values
description += question + ": " + value + "\n";
}
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2023 06:37 AM
Hi @Sam Motley
Try this:
var gr_questions = new GlideRecord('item_option_new');
gr_questions.addQuery('sys_id', 'IN', arr_questionSysIds.toString()); //Single call to the table with all variables we are looking for
gr_questions.orderBy('order'); //Order by the order they are on the catalog item form
gr_questions.query();
var description = "";
while (gr_questions.next()) {
var question = gr_questions.getValue('question_text');
var value = producer[gr_questions.getValue('name')].getDisplayValue();
if (value && value != null && value != '')
{ //only get variables with values
description += question + ": " + value + "\n";
}
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2023 07:41 AM
thanks @Peter Bodelier i had to add "false" to the first value condition but other than that worked a treat many thanks!
regards, sam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2023 06:38 AM
You can try using JSUtil API's nil() or notNil()
Regards,Sushant Malsure
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2023 06:39 AM
Hello @Sam Motley
Just replace your line with :-
if ((value != "false") || (value != null))
you have used to equals in your code, it should be one
Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.
Regards,
Samaksh