GlideappVariablePoolQuestionSet - Question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2024 11:04 AM
I am using for a specific notification an email script found on this forum (which is awesome to be able to do btw), where it automatically adds all non-empty variables from the RITM into a notification. This is fine since its just a dump of values that ends up emailing to Salesforce for email2case input.
I have another ask though, where I think I can leverage this and am curious if I am on the right track for a solution or not.
For approval notifications, I am being asked to include SOME variable inputs into the notification. These would change per item. If I add a field on the variables called "include in notifications" for example, can I re-use the non-empty variable email script below, add a condition to check if this new field is TRUE, and add those variables (only those) to this new notification?
This seems like a potentially easier method than fixing this per-item, and instead I can just toggle the few variables per item I want included, and they will just show up in the notification.
My thoughts are along where the IF check below is checking for empty (no-size), would I just add && in there for a field being true on the variable, or can I not do that when using this method? Is there a better idea to do this? Not at all familiar with "GlideappVariablePoolQuestionSet".
(function runMailScript(current, template, email, email_action, event) {
var item = new GlideRecord("sc_req_item");
item.addQuery("sys_id", current.request_item);
item.query();
while (item.next()) {
var keys = new Array();
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(item.sys_id);
set.setTaskID(current.sys_id);
set.load();
var vs = set.getFlatQuestions();
if(vs.size() == '0' || vs.size() == '')
{
return;
}
else
{
template.print("<hr style='width: 98%;' /><p><b><u>Task Details</u></b></p>");
for (var i = 0; i < vs.size(); i++) {
if (vs.getLabel() != "" && vs.getDisplayValue() != "" && vs.getDisplayValue() != 'false' && vs.get(i).getDisplayValue() != 'false' && vs.get(i).getDisplayValue() != '') {
template.print("<p><b>" + vs.get(i).getLabel() + "</b>: " + vs.get(i).getDisplayValue() + "</p>");
}
}
}
}
})(current, template, email, email_action, event);