Async RestMessageV2 result processing - getting the original record?

Max Nowak
Kilo Sage

Hi,

TL;DR: I'm looking for a way to:

1. Trigger an asynchronous REST message when saving an Incident under certain conditions
2. Capture the result of that REST call
3. Update the incident that originally triggered the REST message with information from the result.

 

I have a BR that triggers on before update / insert of an incident with a few conditions. This BR calls the REST API of a different system, and, in theory, the result of that is used to update the incident that was just saved with additional information.

Up until now, I've just used the synchronous execute() to send the REST message, and immedeately processed the result in the BR. This meant that I could still access the incident via "current", and update it accordingly.

Now, although the REST call to the other system is usually quick, and I really only need to know if the transaction was successful (i.e. if it returned HTTP 200), it's sometimes unreachable due to network problems or whatever (not really my department), and I don't want the instance locking up and waiting for a timeout, so I'd like to use executeAsync().

I've read the Best practices for handling scriptable outbound REST and SOAP messages on the Now Platform KB article, which explains how to deal with executeAsync and processing the result, but my problem is, how do I figure out the incident record? I can create a business rule on the ecc_queue table (like it's described in the KB article), so I can see the response to my REST call, but it's just kinda floating in the air - there's no reference to the incident record which originally triggered the REST call (there is a source_record parameter in the outgoing REST call, but that links to the "Save" UI Action). How can I get a link back to my incident?

Or, alternatively, is there a way to not block the UI when waiting for a synchronous execute()-timeout in case the API is unreachable? Maybe triggering an event which triggers a script action which executes the REST call, or something?

I'm grateful for any ideas

1 ACCEPTED SOLUTION

Allen Andreas
Administrator
Administrator

Hello,

You still have access to "current" in an Async business rule. It's best practice to do any type of REST call, etc. in an async business rule. If you need to update the current record, you can setWorkflow(false) on the current object, then update.

Here's support documentation describing that: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0715782

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

1 REPLY 1

Allen Andreas
Administrator
Administrator

Hello,

You still have access to "current" in an Async business rule. It's best practice to do any type of REST call, etc. in an async business rule. If you need to update the current record, you can setWorkflow(false) on the current object, then update.

Here's support documentation describing that: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0715782

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!