Part 2: Manipulate Complex Internet Data in Flow Without Code

Working with Rich Web Data in Flow

Review Part 1

Let’s recall the problem we’re trying to solve. The web data that’s returned by our Mulesoft product API packs three different SKU’s into a single ‘WebProduct’. Every time we get a result from this API, we need to unpack it and create multiple Product records in Salesforce:

This image has an empty alt attribute; its file name is image-2.png

Here’s the flow we’ll use:

The two Extract assignment elements are extremely important: they take the two Lists that are part of the product and store them in variables. But we handle them slightly differently. Recall that this is what the object looks like:

Because the picture URLS are simple strings:

we can create a standard collection variable of type Text to store them as a group:

But the identifiers are more complicated:

so we store them in a resource that uses the new Apex-Defined type:

Here’s how we configure one of the resources we’ll use:

Note how you select the specific Apex Class that indicates the structure of the data you’ll be storing.

Extracting Subobjects

An important part of the process is extracting copies of the subobjects (in our case it’s the SKU identifiers and the URL Product Images) into record collection variables that use the new Apex-Defined type. Once the data is in record collection variables, we can Loop over it in Flow.

Note the use of dot notation in the Value field. I was able to select this value without typing:

However if you need to go more than one level deep, you’ll have to type in the dot notation yourself, as in the case of the Pricein this example:

Recall that our goal is to end up with three products. We generate the product data by looping over the identifiers and assembling a collection of products. A second loop enables us to add the appropriate picture URL to each of the products. Finally, we save the collection of records to Salesforce.

Good luck with your flows!