The below are examples of how you can manipulate records in an array.
Illustrated below is an example of a JSON payload that has an array.
To remove an email domain from the Email field (trim a field with a specific number), you can use the code in the below Calculator step as shown in the below image. In this example, we are removing the “@gmail.com”.
The code in the below Calculator step.
The below page is the output where the email domain in the email addresses in the Email field have been removed.
To remove records that have a null primary key/field in an array, the following will assist:
In this example, the 2nd record in the array has a null primary field as shown in the below image.
Illustrated below is the code that is used in the Calculator step that will remove the entire record where there is a null value for the Name field.
Illustrated in the below page is the output where the 2nd record is removed.
To manipulate the values in an array based on a value in a field outside of the array, the following will assist:
In this example, changes to the Status field in the array is being made based on the Account field that is out of the array and on the value that is in the isUsed field. The below image is the output of the source data that is in the Record Generator.
Illustrated below is the code that is used in the Calculator step.
The below page is the output of the code in the Calculator step where the Status value is changed if the Account value is equal to “12345” and based on the value in the isUsed field.