Logs, Errors, Outputs

When working with Streamscript, users have access to three types of output:

  1. Errors
  2. Logs
  3. Returned values


We'll modify the script below to show an example of each type.

 

1. Errors

An error in your script (that is not wrapped with try ... catch) will halt the flow. Its error details will be written to the panel on the right. The line number related to the cause and some context about the error is always provided.

In the scenario below, the script calls out to an exchange rate service.

# Streamscript
$http = GET 'open.er-api.com/v6/latest/EUR' # fails without remote site setting
$result = JSON-Decode $http.body
return $result.rates.USDTry

No remote site setting for api.exchangerate.host has been set. So the flow halts and details of the error are shown like this:

Screen flow errors

Other flow errors

In a screen flow, the error will be written to the right of the Debug Details. In an autolaunched flow, the error will be written to the right of the Flow Builder.

 

2. Logs

Users can inspect specific values mid script to aid with development. Use the Log command as highlighted below:

# Streamscript
$Http = GET 'open.er-api.com/v6/latest/EUR'
Log `Callout result: $Http.status`
$result = JSON-Decode $Http.body
return $result.rates.USDTry

Screen flow logs

Other flow logs

Everything logged in any Streamscript action is also available to the next step using the 'log' output. Log is a text value and each item is separated by a new line.

 

3. Returned output

When a script returns any value, it appears in the Debug Details. For example, this exchange rate logic may be modified to return the entire $result instead of just the USD rate:

# Streamscript
$http = GET 'open.er-api.com/v6/latest/EUR'
$result = JSON-Decode $http.body
return $resultTry

No need to specify the returned output type - Streamscript will automatically assign a number to the num output variable, a record to the record variable and so on.

Screen flow returns

Other flow returns

In summary: users have access to logs, errors, and returns in the Flow Builder. When running a script in flow, any error and its line number can be seen in the Debug Details panel.

 

 

Getting started with Streamscript
Install from the Salesforce AppExchange
Package install link: /packaging/installPackage.apexp?p0=04tGA000005NDq5