eventQueue not firing email - using nowDateTime() Method - Change Managment

Laurie Marlowe1
Kilo Sage

Hello,

We have a requirement to send an email to the Change Management group if the Planned Start time is 8 hours in the future from the current time.

I created an onBefore business rule.  Here is my code:

(function executeRule(current, previous /*null when async*/) {

	var gdt = new GlideDateTime(gs.nowDateTime()); //get the current date and time from the server
	gdt.addSeconds(28800); //add 8hours in milliseconds because this is how the server thinks
	gs.addInfoMessage(gdt.getValue());  //this is working
	gs.addInfoMessage(gs.nowDateTime()); //this is working
	if(current.start_date < gdt.getValue()){ //gdt value is 8 hours in the future
		
		gs.addInfoMessage('A notification has been sent to the Change Manager as this may be considered as an expedited change.'); //this is working
		gs.eventQueue('change.expedited', gdt, gs.getUserID(), gs.getUserName()); //email not sent
		
	}
	

})(current, previous);

 

The gs.eventQueue is not firing the change.expedited event.

The event is registered.

The email is set to:

find_real_file.png

 

find_real_file.png

What am I doing wrong?

Thank you in advance,

Laurie

 

1 ACCEPTED SOLUTION

Can you make sure there is no html error on what will it contain section of notification.

View solution in original post

21 REPLIES 21

Anurag Tripathi
Mega Patron
Mega Patron

Hi Laurie,

The email needs to go against a particular record, so the second parameter should be a glide record to a ticket or current. It wont work for gdt. 

gs.eventQueue() Method

The eventQueue() method is part of the GlideSystem server-side API. The eventQueue() method inserts an event in an event queue. The eventQueue() method is typically passed four parameters but can also take an optional 5th parameter:

  • Event name. Enclose the event name in quotes.
  • GlideRecord object, typically current but can be any GlideRecord object from the event’s table.
  • Any value that resolves to a string. This is known as parm1 (Parameter 1). Can be a string, variable that resolves to a string, or method that resolves to a string.
  • Any value that resolves to a string. This is known as parm2 (Parameter 2). Can be a string, variable that resolves to a string, or method that resolves to a string.
  • (Optional) Name of the queue to manage the event.

Please mark my answer correct if it solves your issue.

-Anurag

-Anurag

FIKRI BENBRAHIM
Kilo Guru

Hello Laurie,

 

I you need to trigger the notification against the current record. Thats why you should put: current in the second parameter of you eventQueue call.

I have already had the  same issue and i had solved it like so.

You should follow this link and keep the condition upon which you fire the event.  

Please, if you find this helpful or correct, mark it.

 

Kind regards

FIKRI BENBRAHIM Mohamed Jawad

Alikutty A
Tera Sage

You may need to change the following line from

gs.eventQueue('change.expedited', gdt, gs.getUserID(), gs.getUserName()); //email not sent

To 

gs.eventQueue('change.expedited', current, gs.getUserID(), gs.getUserName()); //email not sent

Laurie Marlowe1
Kilo Sage

All,

I changed to:

gs.eventQueue('change.expedited', current, gs.getUserID(), gs.getUserName()); //email not sent

Email still not sending.

I checked the event registry, and it looks good:

 

find_real_file.png

Still not working 😞

Any other ideas?

 

Thanks,

Laurie