Select to view content in your preferred language

Dashboard table advanced formatting

1097
2
Jump to solution
07-21-2023 06:08 AM
BugPie
by
Frequent Contributor

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: ''
},
}
}

1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

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: ''
},

 

 

View solution in original post

2 Replies
KenBuja
MVP Esteemed Contributor

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: ''
},

 

 

BugPie
by
Frequent Contributor

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. 

0 Kudos