Looking for an example of how to apply the advanced formatting of a Dashboard list that evaluates a string field for a comma. IF the comma exists then I need to return the background cell as red.
I've been able to get formatting working to evaluate date fields for how many days out from today but I can't seem to get anything working for my comma example. This is what I came up with based on what has worked for me in the past but the table does not get formatted and stays in the original formatting.
var gpm = $datapoint["mystringfield"];
var hasComma = Find(mystringfield, ",");
var isGreaterThanMinusOne = hasComma > -1,"#D94534";
return {
cells: {
number: {
displayText: $datapoint["number"],
textColor: '',
backgroundColor: '',
textAlign: 'left',
iconName: '',
iconAlign: '',
iconColor: '',
iconOutlineColor: ''
},
gpm: {
displayText: $datapoint["mystringfield"],
textColor: '',
backgroundColor: isGreaterThanMinusOne,
textAlign: 'left',
iconName: '',
iconAlign: '',
iconColor: '',
iconOutlineColor: ''
},
creationdate: {
displayText: $datapoint["datefield"],
textColor: '',
backgroundColor: '',
textAlign: 'left',
iconName: '',
iconAlign: '',
iconColor: '',
iconOutlineColor: ''
},
}
}
Solved! Go to Solution.
There are two issues with your code. First, the arguments in Find function are reversed. Second, the backgroundColor property needs to be a color code;
var gpm = $datapoint["mystringfield"];
var bgColor;
if (Find(",", gpm) > -1) bgColor = "#ff0000";
//
gpm: {
displayText: $datapoint["mystringfield"],
textColor: '',
backgroundColor: bgColor,
textAlign: 'left',
iconName: '',
iconAlign: '',
iconColor: '',
iconOutlineColor: ''
},
There are two issues with your code. First, the arguments in Find function are reversed. Second, the backgroundColor property needs to be a color code;
var gpm = $datapoint["mystringfield"];
var bgColor;
if (Find(",", gpm) > -1) bgColor = "#ff0000";
//
gpm: {
displayText: $datapoint["mystringfield"],
textColor: '',
backgroundColor: bgColor,
textAlign: 'left',
iconName: '',
iconAlign: '',
iconColor: '',
iconOutlineColor: ''
},
Yes! Thank you KenBuja, this is what I needed. I struggle with the syntax and formatting for if statements. Thank for advancing my knowledge of Arcade formatting, I appreciate it.