Hi Guys,
I am not an expert of Java script but I used chat got to get a java script which will take input as value from my template column which is basically my API mutation
EX: of a row of my template column
{
"kind": "add-row-to-table",
"tableName": "native-table-jWEMMuChAFBW3berD6UM",
"columnValues": {
"Name": "ughRV70bRrmMxq59sNLtCg",
"hUS5E": "Prajwal Devaraj",
"3Fbda": "false",
"WBVZ6": "false",
"TeIW1": "false",
"VA1A4": "ughRV70bRrmMxq59sNLtCg"
}
}
I am passing this column as p1 to my java script below
// Global array to hold the combined column values from all rows
let jsonArray = [];
function processCreatorAPIMutation(p1) {
try {
// Check if p1 is a string (i.e., needs to be parsed) or an object
let rowObject = typeof p1 === "string" ? JSON.parse(p1) : p1;
// Check if the rowObject has 'columnValues', and push its value to the global jsonArray
if (rowObject && rowObject.columnValues) {
jsonArray.push(rowObject.columnValues);
}
} catch (error) {
console.error("Error parsing JSON:", error, "Input data:", p1);
}
return jsonArray; // Return the combined array after each invocation
}
// The variable 'p1' will be automatically passed from Glide.
// The global jsonArray will accumulate the results from each row.
let result = processCreatorAPIMutation(p1);
console.log(result); // This will output the cumulative JSON array of column values
Multiple tries lead me to this script which gives me the following error
Want to know what is the input which is given as p1, is it a string value that is sent internally by glide?
Regards,
Dilip