The CreatorCon Call for Content is officially open! Get started here.

Unable to pull For Each Item data in script

krr
Mega Guru

With Flow Designer we are looping over records from one table and updating / creating records in another. The source table has an address split in to 5 fields (address 1, address 2, city, state, zip). We are trying to merge these together to one larger text box on the target record.

We are using a script to keep this clean and add line breaks, however referencing the fields in the script all return null?

var address1 = fd_data._2__for_each.item.address_1;

These all are null values. How do you reference record fields inside of a For Each loop? Examples below


Flow Designer

find_real_file.png

Address script example

var address1 = fd_data._2__for_each.item.address_1;
var address2 = fd_data._2__for_each.item.address_2;
var addressCity = fd_data._2__for_each.item.address_city;
var addressState = fd_data._2__for_each.item.address_state;
var addressZip = fd_data._2__for_each.item.address_zip;

var result = address1 + '\n';
if (address2 && address2.length > 0) {
    result += address2 + '\n';
}

result += addressCity + '\n';
result += addressState + '\n';
result += addressZip;

return result;

This outputs all nulls to the record

find_real_file.png

Data pill example

If we merge them them using the Data Pill Picker, data populates.

find_real_file.png

This outputs data

find_real_file.png

1 ACCEPTED SOLUTION

krr
Mega Guru

A minute after I posted this I realized it was case sensitive from the input JSON object that came from a REST source.

The autocompletion suggested this

fd_data._2__for_each.item.address_1;

but it needed to be this (capital A)

fd_data._2__for_each.item.Address_1;

View solution in original post

1 REPLY 1

krr
Mega Guru

A minute after I posted this I realized it was case sensitive from the input JSON object that came from a REST source.

The autocompletion suggested this

fd_data._2__for_each.item.address_1;

but it needed to be this (capital A)

fd_data._2__for_each.item.Address_1;