Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

"Additional Information Requested Got a Reply" Email

Elana
Tera Contributor

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:

  1. On which table should the email notification be created? The custom request table or the approval table (sysapproval_approver)?
  2. 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!

Elana_0-1788097871812.png

 

1 ACCEPTED SOLUTION

arnabbhaumik
Tera Expert

 

  • 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).

 

View solution in original post

5 REPLIES 5

arnabbhaumik
Tera Expert

 

  • 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).

 

Thank you this worked except the state is "addinfo" instead of "requested"

IbrarA
Tera Guru


Hi @Elana ,

Your notification sits on "sysapproval_approver", but the state change you're describing happens on your custom request table. A "Record inserted or updated" notification only evaluates when that table is written to, so if nothing touches the approval record when the user supplies the information, the conditions never get a chance to run. You can confirm this by opening one of those approval records and checking its History. If the approval never changed at the moment the request moved back to Awaiting Approval, that's your answer.

Also check the conditions. "state" on "sysapproval_approver" has its own choice list, separate from your custom table's states. Right click the field, go to Configure Choices, and see whether Additional Information Requested and Awaiting Approval exist there. If they don't, those conditions can't match even when the record does update.

On your first question, you can try building the notification on your custom table rather than the approval table, since that's where the state logic lives. The approver then comes through as an event parameter.

Register an event in Event Registry against your custom table. Add a Business Rule on that table with the condition `state` changes from Additional Information Requested to Awaiting Approval. Query `sysapproval_approver` where `source_table` is your table, `document_id` is `current.sys_id`, and `state` is `requested`, then fire the event per pending approver:


gs.eventQueue('x_yourapp.info_provided', current, approvalGr.approver.toString(), approvalGr.sys_id.toString());


You can try this as an after/async rule first. It's easier to debug and you'll see the event land in the queue right away. If the query starts adding noticeable time to the save, switch the same rule to async. Notifications don't need to go out inside the transaction, so async is usually the better place for it long term.

Then set the notification's When to send to Event is fired, select your event, and under Who will receive set the recipient to Event parm1.

If the person making the update is also the approver, the notification gets suppressed unless you tick Send to event creator.


 

Thanks

ibrar

Elana
Tera Contributor

Thank you so much!