Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to get current record details in notification when firing it using Schedule Job

nthumma
Giga Guru

I am doing a POC to fire a daily email notification using Schedule Jobs, Below is my script

try {
var target = new GlideRecord('my_table');
target.addQuery('state', 1);
target.query();     // Issue the query to the database to get relevant records
while (target.next()) {
gs.info(target.number);
gs.eventQueue("my_eventt", current, gs.getUserID(), gs.getUserName());
}

}

catch(ex) {

var message = ex.getMessage();

}

Which works fine , Now when i am sending a notification i want include current record details in that email , how can i achieve this?

1 ACCEPTED SOLUTION

Brad Tilton
ServiceNow Employee
ServiceNow Employee

If this is from a scheduled job, then current doesn't refer to anything. You want to pass the gliderecord object in the second argument of gs.eventQueue(), so I would write that line like this:



gs.eventQueue("my_eventt", target, gs.getUserID(), gs.getUserName());



Then you can reference any of the fields from that record in the notification.


View solution in original post

4 REPLIES 4

Brad Tilton
ServiceNow Employee
ServiceNow Employee

If this is from a scheduled job, then current doesn't refer to anything. You want to pass the gliderecord object in the second argument of gs.eventQueue(), so I would write that line like this:



gs.eventQueue("my_eventt", target, gs.getUserID(), gs.getUserName());



Then you can reference any of the fields from that record in the notification.


nthumma
Giga Guru

Brad Tilton (Cloud Sherpas)


Thanks, than in notification should i say target.my_column or ${target.my_column} ?


Brad Tilton
ServiceNow Employee
ServiceNow Employee

In the notification you would just do ${my_column} or you can reference it with current. The notification objects don't change no matter what the name of the object you pass is.