adding arcade expression used in advanced formatting

283
2
Jump to solution
02-22-2024 12:50 PM
Labels (1)
clt_cabq
Occasional Contributor III

I have used the advanced formatting to calculate the number of days since a location was inspected, if that value is over 99 the background in a list item turns red. I'd like to be able to display that value in the text of the list, but cannot figure out how to convert that from the advanced formatting code to a value that can be shown elsewhere. In the screen shot below, I'd like to have the text read "It has been XX days since this property was visited" positioned after the last visit date.

clt_cabq_0-1708634859680.png

My code for the formatting looks like this:

// calculates the number of days since a location has been inspected, if greater than 100 days then the background turns Red
var daysSince = round(DateDiff(Today(), $datapoint.LastInsp,'days'))
var alert = 100
var bkgrnd = IIF(daysSince > alert,'#FF7f7f','')
return {
  textColor: '',
  backgroundColor: bkgrnd,
  separatorColor:'',
  selectionColor: '',
  selectionTextColor: '',
}

 

0 Kudos
1 Solution

Accepted Solutions
marksm_macomb
Occasional Contributor

You need the attribute section of the return statement, like this:

var daysSince = round(DateDiff(Today(), $datapoint.LastInsp,'days'))
var alert = 100
var bkgrnd = IIF(daysSince > alert,'#FF7f7f','')
return {
  textColor: '',
  backgroundColor: bkgrnd,
  separatorColor:'',
  selectionColor: '',
  selectionTextColor: '',
   attributes: {
     numDays: daysSince,
   }
}

 

You would then call it in your HTML list with {expression/numDays}

View solution in original post

2 Replies
marksm_macomb
Occasional Contributor

You need the attribute section of the return statement, like this:

var daysSince = round(DateDiff(Today(), $datapoint.LastInsp,'days'))
var alert = 100
var bkgrnd = IIF(daysSince > alert,'#FF7f7f','')
return {
  textColor: '',
  backgroundColor: bkgrnd,
  separatorColor:'',
  selectionColor: '',
  selectionTextColor: '',
   attributes: {
     numDays: daysSince,
   }
}

 

You would then call it in your HTML list with {expression/numDays}

clt_cabq
Occasional Contributor III

@marksm_macomb thanks! much easier than I realized. I had tried something similar to that but didn't work so something must have been formatted incorrectly in my previous attempt.