Undefined values showing in email notification

othomas1
Kilo Guru

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);

 

 

 

 

find_real_file.png

12 REPLIES 12

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);

 

 

find_real_file.png

 

Munender Singh
Mega Sage

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

 

i updated those parameters to

  • current.u_number
  • current.u_class
  • current.u_group_all

 

And i am still getting undefined values.

Chaitanya Redd5
Tera Guru

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

Hi Chaitanya,

I updated the script as suggested and it appears to have removed some content

 

 

find_real_file.png