How to join a key and value pair in an object

The below image is an example of a flow where a Record Generator step is used as a source step.

In the Record Generator step, it is populated with a data load as per the image below.

image

Illustrated in the image below is the output of the data load when testing the Record Generator step.

The image below contains the code in the calculator step that is used to join a key and value pair in an object.

image

Copy and paste the below code in your calculator step:

let inputRecord=input.record;

let newObj={};

for (let k in inputRecord.data)
{
newObj[k]=inputRecord.data[k].value;
}

inputRecord.Answers = newObj;
return inputRecord

Highlighted in the below image is the new object “Answers” that was created which contains the output/ results of the value being paired with a key.

image

1 Like