How to convert a value to a field in an object & set the value as null

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

image

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.

image

The image below contains the code in the calculator step that is used to convert a value to a field in an object and to set the value as a null.

image

Copy and paste the below code in your calculator step:

let inputRecord=input.record;

for (let key in inputRecord.result) {
let obj = inputRecord.result[key];

let value = obj[“full_field_key”];
obj[value] = null;

delete obj[“full_field_key”];
}

return inputRecord;

The below image is the output/ results. Highlighted are the new fields that were previously values and their values have been set to null.

image