I have created notification and added email script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi,
I have created notification and added email script. I have created on Approval table and Send to when record inserted or updated and who will receive is approver and what it will contain have used email script to set subject.
Please find attached screenshot :
To test that when order guide is submitted it should create ritm and for each ritm approval will sent and for each ritm approval email should sent as per story requirement. I have added above script as trigger condition. It is not creating email log for each ritm to send approval email to approver. Please help me with that asap.
Can you please check above script and correct that.
Regards,
Nivedita
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi,
The issue is happening because In the Approval table, sysapproval actually references the Task table, so it does not always directly match an RITM record.
Because of that, the GlideRecord lookup on sc_req_item fails, the condition returns false, and the notification does not trigger. That is why no email log is created.
the below code might resolve the issue please check;
(function () {
gs.info('[LEGAL ASSESSMENT NOTIF] START');
gs.info('[LEGAL ASSESSMENT NOTIF] Approval sys_id: ' + current.sys_id);
gs.info('[LEGAL ASSESSMENT NOTIF] sysapproval: ' + current.sysapproval);
if (!current.sysapproval) {
gs.info('[LEGAL ASSESSMENT NOTIF] EXIT: sysapproval is empty');
return false;
}
var approvalRecord = current.sysapproval.getRefRecord();
if (!approvalRecord) {
gs.info('[LEGAL ASSESSMENT NOTIF] EXIT: sysapproval record not found');
return false;
}
// Make sure it is actually an RITM
if (approvalRecord.getTableName() != 'sc_req_item') {
gs.info('[LEGAL ASSESSMENT NOTIF] EXIT: Not an RITM approval');
return false;
}
gs.info('[LEGAL ASSESSMENT NOTIF] RITM found: ' + approvalRecord.number);
gs.info('[LEGAL ASSESSMENT NOTIF] cat_item_guide sys_id: ' + approvalRecord.cat_item_guide);
if (!approvalRecord.cat_item_guide) {
gs.info('[LEGAL ASSESSMENT NOTIF] EXIT: Order Guide is empty on RITM');
return false;
}
var ogName = approvalRecord.cat_item_guide.getDisplayValue();
gs.info('[LEGAL ASSESSMENT NOTIF] Order Guide Name: ' + ogName);
var match = (ogName === 'Legal Impact Assessment');
gs.info('[LEGAL ASSESSMENT NOTIF] Match result: ' + match);
return match;
})();
If this resolved your issue, please mark this response as the correct answer and give it a like
