- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2024 05:20 AM - edited 05-27-2024 05:21 AM
Hi All,
We have an existing script to show the RITM variables in the notification. However, its also showing the variables with false values. Can you suggest how to hide the false variable value from the below script.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2024 05:26 AM
Hi @Koyel Guha ,
Check the below code:
template.print("<p></p>Requested items:\n");
var gr = new GlideRecord("sc_req_item");
gr.addQuery("request", current.sys_id);
gr.query();
while (gr.next()) {
var stage = gr.stage.getDisplayValue();
if (JSUtil.nil(stage))
stage = gr.stage.getChoiceValue();
template.print(gr.number + ": " + gr.cat_item.getDisplayValue() + ", Stage: " + stage + "\n");
template.print(" \n ");
template.print(" More details:\n");
for (key in gr.variables) {
var v = gr.variables[key];
var question = v.getGlideObject().getQuestion();
var label = question.getLabel();
var displayValue = v.getDisplayValue();
if (label && displayValue && displayValue.toLowerCase() !== 'false') {
template.space(4);
template.print(' ' + label + " = " + displayValue + "\n");
}
}
}
Result:
1. here variable "advance" is empty. In email body the above script didn't print "advance"
2. here variable "tt" is not checked & select box "Bu 2" is false & "advance" is empty. In email body the above script didn't print "advance"
If my answer helped you in any way, please mark it as helpful or correct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2024 03:03 PM
Hi @Koyel Guha,
Can you elaborate on what you mean by false values?
My guess is that it should cover the following scenarios:
- No value is provided for the variable
- A checkbox-type variable is not selected
- Select box-type variable where false selected
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2024 03:09 AM
Hi James,
You have mentioned the correct scenarios above.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2024 06:16 AM
Hi @Koyel Guha ,
Please try this code. I have highlighted the changes suggested in bold:
Palani