How to delete a duplicate record/ element in an array

The below example is how to delete a duplicate record/ element in an array.

Illustrated below is an example payload that is used in a Record Generator source step. As shown in the image, there are 2 records/ elements in the PersonList array that are the same/ duplicated.

image

The code in the Calculator step as shown in the image below is used to delete the duplicate record/ element in the array and .

image

The below code can be used to copy and paste in your Calculator step. The array name has to be changed to the array name in your dataset.

let inputRecord=input.record;

inputRecord.PersonList = input.record.PersonList.filter((check, index, self) =>
  index === self.findIndex((t) => (
    t.Name === check.Name
  ))
);


return inputRecord;

The output of the above code is shown in the image below.

image

How to manipulate records in an array