I'm using JavasScript to write the script for Numbers automation. I believe its called JXA in this context? Based on: https://leancrew.com/all-this/2022/05/javascript-vs-applescript/
Anyway here's a function that colorize the row based on a condition:
function colorize(row) {
const blue = [22085.295, 49609.995, 65535]
const rs = row.cells[2].value()?.indexOf('PRUDENTIAL')
if (foundAndDefined(rs)) {
console.log(row.backgroundColor);
row.backgroundColor = blue
}
}
However, I don't want to override the color if a color is already defined.
But trying to console.log the backgroundColor throws Error -1700: Can't convert types.
How can we check if there's any existing value or console.log the value if any?
Ok figured it out, simply call backgroundColor as a function like
backgroundColor().Full example:
Where
isNullis a custom function not shown