- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello Everyone,
I have developed a custom service with its own table and custom states. The service is submitted through a Record Producer, and upon submission, a sequence of approvals is triggered.
My requirement is the following:
When an approver requests additional information, the request state is changed to "Additional Information Requested". After the Opened By user provides the requested information and the request moves back to "Awaiting Approval", I would like the approver to receive an email notification informing them that the requested information has been provided.
My questions are:
- On which table should the email notification be created? The custom request table or the approval table (sysapproval_approver)?
- What conditions should be used to trigger the notification only when the request transitions from Additional Information Requested back to Awaiting Approval?
I tried creating the notification on the approver table (sysapproval_approver) using the configuration shown in the screenshot below, but the notification was never triggered.
The relevant states in my custom table are:
- Additional Information Requested (custom numeric value)
- Awaiting Approval
Any guidance on the correct notification setup would be appreciated. Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
- Create an after update Business Rule on your custom table, condition = the same changesFrom() logic above.
- In the script, query sysapproval_approver for records where source_table = your table, document_id = current.sys_id, and state = 'requested' (i.e., still pending).
- For each result, gs.eventQueue('x_yourapp.info_provided', current, approverGr.approver, approverGr.sys_id).
- Create the Notification triggered by that Event (not Record Updated), with recipient set to "Event parm1" (the approver's sys_id/user).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Keep it async and one important thing, put the state changesFrom condition in the Filter Condition field on the BR form, not inside the script body. Async BRs run with previous as null so if you write changesFrom() inside the script it silently does nothing. No error, no log, event just never queues. Easy thing to miss.
(function executeRule(current, previous /*null when async*/) {
var approvalGr = new GlideRecord('sysapproval_approver');
approvalGr.addQuery('source_table', current.getTableName());
approvalGr.addQuery('document_id', current.sys_id);
approvalGr.addQuery('state', 'requested');
approvalGr.query();
while (approvalGr.next()) {
gs.eventQueue('x_yourscope.info_provided', current, approvalGr.approver.toString(),
approvalGr.sys_id.toString());
}
})(current, previous);
state = 'requested' makes sure you are only firing the event for approvers who are still pending. And do not remove the .toString() on those fields, without it parm1 does not serialize correctly and your notification recipient comes back empty.
After saving, check System Log then Events first before testing the full flow. Confirm the event landed and then move on.
