Event fired but notification not sent in servicenow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 04:03 AM
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:
Notification:
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 04:18 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 05:55 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 06:15 AM
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);
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2023 09:40 PM
Hello @Sruthi17 ,
if my answer helped you please mark it as correct and close the thread.
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.