Salesforce flow calling an exchange rates API in 90 seconds. Uses template strings, URL variables, the dot operator to traverse JSON collections, and math commands. Returns data available as a flow resource.
0:10 Set the start/end dates
0:42 Demo the exchange rate logic
0:50 Using merge fields for the URL
0:55 HTTP GET command
1:00 Show the JSON manually
1:11 Return the average
Here's a quick demo. Let's say the US sales team needs the Japanese price list updated regularly. We'll calculate those prices using an average exchange rate over a month using Streamscript.
We begin with a start date.
I'll create a date resource and we'll do the same for the month end. Next, we use a Streamscript step and paste in the exchange rate logic.
Click save and then click Debug. Our script ran. It used the start date and end date to define the month range to call out to the exchange rate service and calculated the average rate.
Let's take a closer look at this logic in detail.
We built up the URL using the start date and end date from those flow variables. Then we call out to the rate service. You could also try this in your web browser like this.
Finally, we use the average command to extract and loop over the Japanese rates. Because we return the average, it becomes available in the outputs on the Flow canvas.
So summing up, we needed exchange rates for a price list. We called out to a service to get the data using Streamscript. Then we calculated the average and the result can now be used in Flow.
Getting started with Streamscript
Install from the Salesforce AppExchange
Package install link: