Arcade Expression to Control Selection Color in Dashboard List

727
3
Jump to solution
08-23-2023 06:54 AM
BaileyHorn
New Contributor II

Hello! Looking for help writing Arcade script to define a specific selection color for a variable in a Dashboard List. The script I have so far is written out below. When I run the script the selection color does not show up in my Dashboard List. Please help, and thank  you. 

 

var green = When($datapoint.project_status == "Active / Awarded", '#55ff00','')

return {
textColor: '',
backgroundColor: '',
separatorColor:'',
selectionColor: green,
selectionTextColor: '',
// attributes: {
// attribute1: '',
// attribute2: ''
// }
}

0 Kudos
2 Solutions

Accepted Solutions
JenniferAcunto
Esri Regular Contributor

 

I don't see anything wrong with the arcade expression. Are you sure your field name and/or value is correct? One thing I like to do if I'm having issues returning colors, is to return it as an attribute and add that to the list so that I can see exactly what value is being returned. This helps me narrow down where the issue is. 

 

JenniferAcunto_0-1692821971480.png

Also note, that the selection color doesn't appear until you have set up an action in your list. Without an action setup, clicking on a list item doesn't select anything and therefore doesn't bring up the selection color. 

 

- Jen

View solution in original post

0 Kudos
JenniferAcunto
Esri Regular Contributor

You would need to return the color hex value as an attribute and then plug that directly into your HTML of the list. 

JenniferAcunto_0-1692892100899.png

 

- Jen

View solution in original post

3 Replies
JenniferAcunto
Esri Regular Contributor

 

I don't see anything wrong with the arcade expression. Are you sure your field name and/or value is correct? One thing I like to do if I'm having issues returning colors, is to return it as an attribute and add that to the list so that I can see exactly what value is being returned. This helps me narrow down where the issue is. 

 

JenniferAcunto_0-1692821971480.png

Also note, that the selection color doesn't appear until you have set up an action in your list. Without an action setup, clicking on a list item doesn't select anything and therefore doesn't bring up the selection color. 

 

- Jen
0 Kudos
BaileyHorn
New Contributor II

Jen, Thank you for the help. A Follow up question for you. How would I change the code to select/highlight/change text color of a specific line of text on my Dashboard List. The script I am running now (see script below) highlights the entire box on my list and changes all of the text color too (See image below). 

 

var colorfas = When (
$datapoint.forecast_actual_scheduled == "Forecast (F)", '#bee8ff',
$datapoint.forecast_actual_scheduled == "Actual (A)", '#d6d6d6',
$datapoint.forecast_actual_scheduled == "Scheduled (S)", '#ffffff', 'n/a')

var colorprojectstatus = When (
$datapoint.project_status == "Active / Awarded", '#55ff00',
$datapoint.project_status == "Cancelled", '#ff0000',
$datapoint.project_status == "Complete", '#ff00c5',
$datapoint.project_status == "In Progress", '#0070ff',
$datapoint.project_status == "On Hold", '#ffff00', 'n/a')

return {
textColor: colorfas,
backgroundColor: colorprojectstatus,
separatorColor: '',
selectionColor: '',
selectionTextColor: '',
// attributes: {
// attribute1: '',
// attribute2: ''
// }
}

 

BaileyHorn_0-1692886079946.png

 

0 Kudos
JenniferAcunto
Esri Regular Contributor

You would need to return the color hex value as an attribute and then plug that directly into your HTML of the list. 

JenniferAcunto_0-1692892100899.png

 

- Jen