We are close but not quite. Using this array as an example:
[{“cell”:“X:1”,“new_value”:“INVESTED FANS”,“previous_value”:“”},{“cell”:“Y:1”,“new_value”:“LOW”,“previous_value”:“”},{“cell”:“Z:1”,“new_value”:“MID-HIGH”,“previous_value”:“”},{“cell”:“AA:1”,“new_value”:“STATUS”,“previous_value”:“”},{“cell”:“AA:57”,“new_value”:“SEND”,“previous_value”:“”},{“cell”:“E:127”,“new_value”:“B”,“previous_value”:“”}]
If we were searching for the value “SEND”, this would be the answer.
{“cell”:“AA:57”,“new_value”:“SEND”,“previous_value”:“”}
Here is the last code you gave me:
export default defineComponent({
props: {
wordToSearchFor: {
type: "string",
label: "Word to Search For",
},
arrayToSearchThru: {
type: "string[]",
label: "Array to Search Through",
},
},
async run({ steps, $ }) {
const changes = steps.trigger.event.changes; // The array of changes
const wordToSearchFor = this.wordToSearchFor; // Word to search for
// Filter changes to find matches in the new_value field
const results = changes
.filter(change => {
// Check if the word exists in the new_value
return change.new_value && change.new_value.includes(wordToSearchFor);
})
.map(change => {
// Map the results to return desired values
const { cell, new_value, previous_value } = change;
return { cell, new_value, previous_value };
});
return results; // Return the filtered and mapped results
},
});
So what should come back is:
“cell”:“AA:57”
“new_value”:“SEND”
“previous_value”:“”},