Hello,
I was looking to create a changeset column which records the names of the edited columns (not values) i.e., Status and Status Reason for each row in table 1. This column will later be used the specify which CRM fields need to be updated downstream. Here is my JS so far, which does not successfully record the changeset.
const tableData = formatDataAsArray({{ table1.data }})
return tableData.map(row => {
const changeset = row.changeSet || {}
const changesetString = JSON.stringify(changeset)
return {
...row,
changeset: changesetString
}
})
Best regards,
Still running into this issue. @SigmaverseDev
ScottR
July 27, 2023, 5:48pm
3
Try removing
formatDataAsArray()
Then, I get ""tableData.map is not a function""
ScottR
July 27, 2023, 6:33pm
5
const tableData = formatDataAsArray( table1.data )
Remove the curly braces too:
The following worked for me:
const tableData = table1.data ;
return tableData.map(row => {
const changeset = row.changeSet || {}
const changesetString = JSON.stringify(changeset)
return {
...row,
changeset: changesetString
}
})
1 Like
Tess
July 28, 2023, 4:01pm
6
Hi @ttam_ei
If this code is in a Javascript query, you'll want to remove double curlies {{}}
.
If you were using a Javascript transformer, then you would want to still use the double curlies.
Tess
July 28, 2023, 4:18pm
7
However, the changeSet will be a different property than .data
.
This post might be helpful for your use case
You could try something like this:
const tableData = formatDataAsArray( table1.data )
return tableData.map((row, index) => {
const changeset = table1.changeSet[index] || {};
const changesetString = JSON.stringify(changeset);
return {
...row,
changeset: changesetString
}
})
Works perfectly. Thank you!
1 Like