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.
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: '',
}
Solved! Go to Solution.
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}
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}
@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.