Best practices for handling scriptable outbound REST and SOAP messages on the Now Platform


Description

execute() vs executeAsync()

If you are using RESTMessageV2 or SOAPMessageV2 within your scripts you may have noticed that there are two ways to execute a call:

When to use execute() and things to think about when using it:

When to use executeAsync() and things to think about when using:

How to switch from using execute() to executeAsync() when it is not fire and forget:

Many scripts using execute() may look something like this -

To switch this over to use executeAsync we must simply move block C out to a business rule that is set on the ECC Queue looking for the response to our asynchronous method

Your new script using executeAsync():

The script of your new sensor business rule (see the "Process Get Stock Quote" business rule as reference for SOAP) -

Using this kind of setup is much safer for the instance as threads will no longer be sitting around doing nothing waiting for possibly long-running services to finish.