Event fired but notification not sent in servicenow

Sruthi17
Kilo Sage

Event fired but notification not sent in ServiceNow, please help me resolve.
Created an event in event registry, and called in scheduled job, event is successfully triggered but notification not sent.

Event Registry:

Sruthi17_0-1692960831507.png

Notification:

Sruthi17_1-1692960859253.png

Sruthi17_2-1692961273977.png

Event triggered successfully

 

I have verified the below 

1. Recipient has valid email address

 

I also have a doubt about the table name in notification. What should be thetable name? I have a scheduled job, in that I call a rest method and based on the response, If the response fails I need to send an email notification to admins.
In this case what should  be the table name?

 

 

4 REPLIES 4

Mohith Devatte
Tera Sage
Tera Sage

hello @Sruthi17 ,

Can you send me the code where you tried to trigger an event ?

 

it should be like object in the event queue method , event table and notification table should be same .Then the notification will trigger.

 

 

 

Hi @Mohith Devatte 

 

Please find the code below

 

var requestBody = gs.getProperty('aims_integration.request_body');
var crewScheduleChangeRequest = new sn_ws.RESTMessageV2();
crewScheduleChangeRequest.setEndpoint(gs.getProperty("aims_integration.end_point.get_crew_schedule_change"));
crewScheduleChangeRequest.setHttpMethod('post');
crewScheduleChangeRequest.setRequestHeader('Authorization', 'Bearer ' + this.getAccessToken);
crewScheduleChangeRequest.setRequestHeader("Content-Type", "application/json");
crewScheduleChangeRequest.setRequestHeader("Accept", "application/json");
requestBody = requestBody.replace("${start_date}", String(this.getTimeStamp("start"))).replace("${end_date}", String(this.getTimeStamp("end")));
gs.info("getCrewScheduleChange : requestBody : " + requestBody);
crewScheduleChangeRequest.setRequestBody(requestBody);
var requestResponse = crewScheduleChangeRequest.execute();
var requestResponseBody = requestResponse.getBody();
var requestResponseStatus = requestResponse.getStatusCode();
gs.log('LeaveManagementUtils | Checking Response status: ' + requestResponseStatus);
if(requestResponseStatus != '200'){
gs.eventQueue('notify.error.leave_management',requestResponse);
}
gs.log("requestResponse= " + requestResponseBody + "," + requestResponseStatus);
var jsonParser = new JSONParser();
var parsedData = jsonParser.parse(requestResponseBody);

 

Event triggered successfully, please find below screenshot

Sruthi17_0-1692968075951.png

 

Hello @Sruthi17,

 

The format to trigger an event from script is the below :
gs.eventQueue("event name", glideobject , email1, email2);

 

In your case use it as:
gs.eventQueue('notify.error.leave_management',current,requestResponseBody,requestResponseStatus);

 

 

 

If my answer solved your issue, please mark my answer as Correct & Helpful based on the Impact

Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.

Hello @Sruthi17 ,

if my answer helped you please mark it as correct and close the thread.

 

If my answer solved your issue, please mark my answer as Correct & Helpful based on the Impact

Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.