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 08:34 AM
Hi,
Please try this out and see if it works for you.
var acl = new GlideRecord('u_cmdb_ci_table_access_parameters');
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.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');
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-02-2019 10:43 AM
Hello Alikutty,
I tried those changes but i am still getting the undefined values.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-02-2019 08:34 AM
1. Remove while loop and add if loop.
2. Have you tried something like this -
acl.getDisplayValue('u_class') OR acl.u_class.name
If it works then try for other variables.
Please mark as Correct Answer and Helpful, if applicable.
Thanks!
Abhishek Gardade
Hexaware Technologies
Abhishek Gardade

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-02-2019 08:45 AM
to get the values of the queried records you should have .next()
Try the below 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');
if(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);
Also i think your query might not be correct. You might have to update current.sys_id with the correct ones
acl.addQuery('u_number', current.sys_id);
acl.addQuery('u_class', current.sys_id);
acl.addQuery('u_group_all', current.sys_id);