- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-11-2022 07:03 AM
I have created a summary field from RITM table and it displays all the variables details there.. But, I could see that empty variables labels are displaying which I want to hidden from the summary. How can I do this?
I'm using below Business Rule to update the Summary details:
(function executeRule(current, previous /*null when async*/) {
// This concatenates all variables into a u_summary field in RITM table
var details = '';
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(current.sys_id);
set.load();
var vs = set.getFlatQuestions();
for (var i=0; i < vs.size(); i++) {
if(vs.get(i).getLabel() != '') {
details += vs.get(i).getLabel() + " = " + vs.get(i).getDisplayValue() + "\n";
}
}
current.u_summary = details;
})(current, previous);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-11-2022 09:59 AM
Hi,
Add below highlighted part in IF condition
if(vs.get(i).getLabel() != '' && JSUtil.notNil(vs.get(i).getDisplayValue()) ){
details += vs.get(i).getLabel() + " = " + vs.get(i).getDisplayValue() + "\n";
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-11-2022 09:59 AM
Hi,
Add below highlighted part in IF condition
if(vs.get(i).getLabel() != '' && JSUtil.notNil(vs.get(i).getDisplayValue()) ){
details += vs.get(i).getLabel() + " = " + vs.get(i).getDisplayValue() + "\n";
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2022 11:50 PM
Thank you @stark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2023 02:32 AM - edited ‎06-07-2023 02:45 AM
@Shruti - Hi, this was really helpful thank you - we added JSUtil.notNil(vs.get(i).getDisplayValue()) ){ to the if condition of our mail script and it removed the empty variables from our variable summary mail script on a notification, which is exactly what we wanted! thank you!
We have one question - We have checkbox variables on some of our record producers, and if these are not selected, their value equals false. Which means they show up on our variable summary on our notification because the value is completed.
What can we add to this same IF condition, to ensure the checkbox variables that are set as false are also not shown on the variable summary as part of our notification? We have tried vs.get(i).getDisplayValue() == 'false' however that didnt work