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 trigger an event by Schedule Job

Lucas11
Tera Contributor

Hello guys!

I have a problem with the eventQueue, it is not triggering the notification and the event is not starting.

Schedule Job:

Captura de Tela 2022-12-14 às 14.39.36.png

All conditions are being met, I did the test and everything passed (there was more "gs.info" in the code).

 

Event:

Captura de Tela 2022-12-14 às 14.28.57.png

Do not know whether the need to put the table. But I saw another example of Schedule Job with eventQueu, which event had no table selected.

 

Notification > When to send:

Captura de Tela 2022-12-14 às 14.47.41.png

Notification > Who will receive:

Captura de Tela 2022-12-14 às 14.49.12.png

Please, if anyone can help me, I'm out of time to deliver this story!
Thank you very much!

TABLE: ast_contract
SCRIPT: 

 

 

var gd = new GlideDate();
gd.addDays(-365);

var gr = new GlideRecord('ast_contract');
gr.addQuery('state', '=', 'active');
gr.addQuery('u_contract_term', '=', '2_years');
gr.query();

while (gr.next()) {
	gs.info(gr.number);
	var startDate = gr.starts;
	gs.info("startdate" + startDate);
	

    if (startDate == gd) {
		gs.info('Entrou if startDate!');
        gs.eventQueue('ipca.changed', 'gr', '');
    }
}

 

 

10 REPLIES 10

See the syntax -

gs.eventQueue('event.name', GlideRecord, parm1, parm2);

 

Please verify it. You will get your answer.