A direct way to return data from a script action for use in later steps or rich text fields

When I use return in a script at the end of an action, the data is JSON.stringified and added to the message object. I would normally end a script with something like this:

// Return contactInfo and the paymentURL 
return {
    contactInfo: htmlString,
    paymentURL: paymentURL
};

When I want to use the data later I have to do this:
<% JSON.parse(args.steps[2].result.message.slice(7)).paymentURL %>

Is there a different way to send outputs so I can call them directly?

I don’t think there is any more efficient way of extracting info from the return message.

1 Like