Undefined values showing in email notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-02-2019 08:28 AM
I have an email script and a notification, my notification is showing "undefined" for certain variables i am trying to reference, does anyone know what this could be the cause of this?
Email script:
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var acl = new GlideRecord('u_cmdb_ci_table_access_parameters');
//var obj = JSON.parse(event.parm2);
acl.addQuery('u_number', current.sys_id);
acl.addQuery('u_class', current.sys_id);
acl.addQuery('u_group_all', current.sys_id);
acl.query();
//acl.getRowCount();
//gs.log('33');
//while(acl.next()){
email.setSubject("CMDB Group ACL Deactivated for " + acl.u_class.getDisplayValue() + " Class ");
template.print('<a href="/u_cmdb_ci_table_access_parameters.do?sys_id=' + acl.sys_id + '">' + acl.u_number + '</a>');
template.print("has been deactivated. The group" + "" + acl.u_group_all.getDisplayValue() + "" + "" + "is no longer active. + '<br/>");
template.print("Please reach out to stakeholders to identify whether a replacement" + "" + acl.u_class.getDisplayValue() + "" + "ACL is needed.<br/>");
gs.log('99');
//}
})(current, template, email, email_action, event);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-02-2019 10:04 AM
I updated the script as below but the values are gone now
Script:
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var acl = new GlideRecord('u_cmdb_ci_table_access_parameters');
acl.addQuery('u_number', 'Number');
acl.addQuery('u_class', 'Class');
acl.addQuery('u_group_all', 'Group');
acl.query();
acl.next();
email.setSubject("CMDB Group ACL Deactivated for " + acl.getDisplayValue('u_class') + " Class ");
template.print('<a href="/u_cmdb_ci_table_access_parameters.do?sys_id=' + acl.sys_id + '">' + acl.u_number + '</a>');
template.print("has been deactivated. The group" + "" + acl.u_group_all.name + "" + "" + "is no longer active. + '<br/>");
template.print("Please reach out to stakeholders to identify whether a replacement" + "" + acl.u_class.name + "" + "ACL is needed.<br/>");
gs.log('99');
})(current, template, email, email_action, event);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-02-2019 08:54 AM
Hi,
I think there is an error in addQuery
var acl = new GlideRecord('u_cmdb_ci_table_access_parameters');
//var obj = JSON.parse(event.parm2);
acl.addQuery('u_number', current.sys_id);
acl.addQuery('u_class', current.sys_id);
acl.addQuery('u_group_all', current.sys_id);
acl.query();
Because how could you pass the current sys_id for all all filters i.e. u_number,u_class and u_group_all.
Kindly,check and fix with the appropriate inputs in addQuery parameters.
Regards,
Munender
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-02-2019 10:40 AM
i updated those parameters to
- current.u_number
- current.u_class
- current.u_group_all
And i am still getting undefined values.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-02-2019 11:45 AM
Hi,
Could you please give a try with below script:
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
// Add your code here
var acl = new GlideRecord('u_cmdb_ci_table_access_parameters');
acl.addQuery('u_number', current.u_number);
acl.addQuery('u_class', current.u_class);
acl.addQuery('u_group_all', current.u_group_all);
if(acl.query());
{
email.setSubject("CMDB Group ACL Deactivated for " + acl.getDisplayValue('u_class') + " Class ");
template.print('<a href="/u_cmdb_ci_table_access_parameters.do?sys_id='+acl.sys_id.toString()+'">'+acl.u_number+ '</a>');
template.print("has been deactivated. The group "+ acl.getDisplayValue('u_group_all') + " is no longer active. + '<br/>");
template.print("Please reach out to stakeholders to identify whether a replacement " + acl.getDisplayValue('u_class') + " ACL is needed.<br/>");
}
})(current, template, email, email_action, event);
Kindly mark my answer as Correct and Helpful based on the impact.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-02-2019 12:53 PM