how to pass values from scheduled job to notification

BanuMahalakshmi
Tera Contributor

Hi,

I have tried the below script to trigger notification from scheduled job, but it didnt pass the value. pls assist me to required changes.

 

Scheduled Job:

 

var gr = new GlideRecord('cmdb_ci_computer');
gr.addQuery('sys_updated_by', '=', 'admin');
gr.addQuery('sys_class_name', '=', 'cmdb_ci_computer');
gr.addQuery('install_status', '=', '1');
gr.addQuery('sys_updated_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()');
gr.query();
while (gr.next()) {
var param1 = gr.name.toString(); 
var param2 = gr.short_description;
var param3 = gr.checked_in;
 gs.eventQueue("PC Email Notification", gr, param1, param2,param3);
}
 
Event Registry:
BanuMahalakshmi_0-1730382906358.png

 

Notification:

 

BanuMahalakshmi_1-1730383279720.png

 

Notification Message:

Good morning,

 

The following computer in your name has not been connected in 30 days:

 

Computer Name                          Days Stale       Description                                          Last Logon Date

${event.param1}                                30                ${event.parm2}                                       ${event.parm3} 

 

Please log on to this computer as soon as possible and let me know once you have done so.  If it is not logged into soon, it will be quarantined.Feel free to contact your local IT support if you have any questions.

 

Thank you,

{Signature Block}

 

 

 

1 REPLY 1

Kieran Anson
Kilo Patron

As you're passing the record "gr" into the event, you don't need to pass any parameters really. In your notification you can just access the values of the record by doing ${name}, ${short_description}, ${checked_in}