Notification not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2024 05:08 AM
Hey Everyone,
I am trying to trigger a notification through background script using event, but email is not triggering, when i checked the event log i can see event has triggered but not sure why it is in ready state every time when i try to trigger. Please see the screenshot. Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2024 04:41 AM
User is active and have valid email id and notification preference is also enabled, I tried with other users as well but no luck, i run BG script multiple times all events are in ready state and not being processed. We also checked there are no long running job in background.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2024 09:04 PM
Hi @sunil maddheshi ,
How are you getting ready state, have done customization on state field? Also check the recipient column, hope you are passing email ids.
If you are doing it in PDI then email wont trigger. to configure email account check this blog: https://servicenowwithrunjay.com/configuring-an-email-account-in-a-servicenow-pdi/
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2024 09:09 PM
Recheck your parameters and the recipients.
Also if you are using it on your PDI, i doubt PDIs are allowed to send emails. Earlier you could but now i doubt it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2024 09:53 PM
@Ankur Bawiskar @Runjay Patel @yuvarajkate
It is customer instance not PDI, I am trying to trigger notification using background script(for testing purpose later will move to schedule job), and using that event in the notification with email body and i have added a recipient in notification which has valid email id. Below is my background script and screenshot of notification.
// send the notification if custom fields in the table has empty value in all the records
var tableName = ['sn_grc_issue', 'sn_grc_task', 'sn_audit_engagement'];
for (var i = 0; i < tableName.length; i++) {
var fieldArr = [];
var dictionaryGR = new GlideRecord('sys_dictionary');
dictionaryGR.addEncodedQuery('elementSTARTSWITHu_^active=true^name=' + tableName[i]);
dictionaryGR.query();
gs.info(dictionaryGR.getRowCount());
while (dictionaryGR.next()) {
checkUnusedField(tableName[i], dictionaryGR.element, dictionaryGR.column_label);
}
gs.info("Un-used fields on table " + tableName[i] + " are " + fieldArr);
if (fieldArr.length > 0) {
gs.info("inside if");
gs.eventQueue('unused_field_event', dictionaryGR, tableName[i], fieldArr);
}
}
function checkUnusedField(table, field_name, field_label) {
var tableGr = new GlideRecord(table);
tableGr.addEncodedQuery('' + field_name + '!=NULL');
tableGr.query();
if (tableGr.getRowCount() == 0) { //field has empty value in all records
fieldArr.push(field_label + " ");
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2024 04:46 AM
Hi @sunil maddheshi ,
Your code is working fine, if recipients have valid email id then it should process the email.
Open the email log in new window and check the processing log.
If found any error or warning then share
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------