Select to view content in your preferred language

Trying to add an alert based on two parameters

01-18-2024 09:28 AM
New Contributor III

I am struggling to get the result I want. Want to set an alert text (in this case 'ALERT' if two criteria are met. It has to be over 10 days old and another attribute cannot be "Mapped in GIS"

I think I got into the weeds and have a mess. I know the str=Find line is not working. I am trying to just find things that contained "mapped" but this line looks to be returning everything. 

Any help would be great. 


var y = NOW();
var z = date($datapoint.DateTieIn);
var w = DateDiff(y,z,'days')
var str=Find("Mapped",Upper($datapoint.GISStatus))
var b = IIf((str>(-1)),5,0)
var c = iif(w>'10',1,0)
var e = Sum(b,c);
var a = iif(e==0,'',

return {
textColor: '',
backgroundColor: '',
selectionColor: '',
selectionTextColor: '',
attributes: {



Here are my variables; 

y= Todays Date

z= Date Tied In

w= Days elapsed since Tie In

str= find only those containing 'Mapped' text 

b=Result of str

c=if over 10 days since tie in give a value 

e= Adding results of the "Mapped" search with Days old value 

a=Based on the sum in e there were 4 possible combinations I only want an alert for 1 which is (0 (not mapped) + 1 (over 10 days old) 



0 Kudos
2 Replies
Occasional Contributor II

Hi Adam,

It's not clear to me what element type you're working with, but perhaps this will put you on the right track. I wrote an expression that checks your two conditions, then changes the background color of a list item if both conditions are met, and also adds the text ALERT to the item.


var DateTieIn = $datapoint.DateTieIn;
var GISStatus = $datapoint.GISStatus;

var moreThanTenDays;
var alert;
var alertText;

IIf(DateDiff(NOW(), DateTieIn, "days") > 10,
    moreThanTenDays = true,
    moreThanTenDays = false

IIf(moreThanTenDays == true && GISStatus != "Mapped in GIS",
    alert = true,
    alert = false

IIf(alert, alertText = 'ALERT', alertText = null);

return {
  textColor: '',
  backgroundColor: IIf(alert, 'red', 'white'),
  selectionColor: '',
  selectionTextColor: '',
  attributes: {alertText:alertText}



The result looks like this:


Here's how the Line item template is configured:


New Contributor III

That's a good reference to keep in my pocket. Thank you I appreciate it!

It doesn't do exactly what I am trying to do. I worked on it to get it to work but had to take a different approach. I want to still clean up my code and when I'm playing around Ill try some of these ideas and see where they go.


Thanks again 

0 Kudos