I am making a parking violation reporting map for code enforment. The need to see what points are open, closed, have had contact or are overdue. I am using Arcade for symbology based on date fields. I can get some but not all the symbology to work. I have limited coding experience and have already spent over 4 hours on this. I have attached my code document with my notes on what is working
Symbology I need to change on its own as the date changes within fields and also on calendar. 😀 are what I have working.
Solved! Go to Solution.
It's much easier to work with your code when you use the "Insert/edit code sample" button. Click the three dots at the end of the icon bar, then select the </> icon.
I'm guessing you're showing three different versions of the same script you'd like to run, but if I'm incorrect, please let me know. What are the some of the dates you'd expect to see in your data? You can test your script in the Playground like this to see how it works with a variety of dates.
var clean_up_date = null;
var contact_date = Date(2023,10,6);
var reporting_date = Date(2023,10,4)
var citation_date = Date(2023,10,5);
When (!IsEmpty(clean_up_date), "Removed",
!IsEmpty(reporting_date) && DateDiff(contact_date, Date (reporting_date), 'days') >=3, "Over Due- Warning three days over Reporting",
!IsEmpty(reporting_date) && DateDiff(contact_date, Date (reporting_date), 'days') <=2, "Contact Made 1",
DateDiff(citation_date, Date(contact_date), 'days') >=3, "Over Due- Citation three days over Warning",
DateDiff(citation_date, Date(contact_date),'days') <=2, "Contact Made 2",
"Open")
Thank you! I didn't know how to add code to the display. Yes I was showing my test of the script so people knew what I had already tried. The dates I expect to see are: clean up, reporting, contact, citation. They all have date fields to pull from. I have been testing it but symbology just wasn't showing. This is my first time trying to use Arcade (any code) to make symbology changes. So the help is very appreciated. Your example lead me to the right place to get it working.
This is what I have gotten the script to. It is not pretty but it seems to be working.
When(!IsEmpty($feature.clean_up_date),"Removed", //symbol changes to green when date field is not null (closed condition)
!IsEmpty($feature.removal_date),"Tow", //symbol changes to orange when date field is not null
!IsEmpty($feature.reporting_date) && IsEmpty($feature.contact_date) && IsEmpty($feature.citation_date) && IsEmpty($feature.clean_up_date) && DateDiff (Now(), Date ($feature.reporting_date), 'days') >=3, "Over Due- 3 days since Reported", //symbol changes to black/overdue when reporting date is 3 days over and contact, citation, or clean up date fields have no entry
!IsEmpty($feature.contact_date) && IsEmpty($feature.citation_date) && IsEmpty($feature.clean_up_date) && DateDiff (Now(), Date ($feature.contact_date), 'days') >=3, "Over Due- 3 days since Warning", //symbol changes to blue/overdue when contact date is 3 days over and citation or clean up date not entered
!IsEmpty($feature.citation_date) && IsEmpty($feature.clean_up_date) && DateDiff (Now(), Date ($feature.citation_date), 'days') >=3, "Over Due- 3 days since Citation", //symbol changes to Purple/overdue when citation date is 3 days over and clean up date not entered
!IsEmpty($feature.reporting_date) && DateDiff($feature.contact_date, Date ($feature.reporting_date), 'days') <=2, "Contact Made", //symbol changes to yellow/contact made when contact date is under three days from reporting date. Both fields have entry
"Open")//symbol changes to red/open when all other conditions are not meet
It's much easier to work with your code when you use the "Insert/edit code sample" button. Click the three dots at the end of the icon bar, then select the </> icon.
I'm guessing you're showing three different versions of the same script you'd like to run, but if I'm incorrect, please let me know. What are the some of the dates you'd expect to see in your data? You can test your script in the Playground like this to see how it works with a variety of dates.
var clean_up_date = null;
var contact_date = Date(2023,10,6);
var reporting_date = Date(2023,10,4)
var citation_date = Date(2023,10,5);
When (!IsEmpty(clean_up_date), "Removed",
!IsEmpty(reporting_date) && DateDiff(contact_date, Date (reporting_date), 'days') >=3, "Over Due- Warning three days over Reporting",
!IsEmpty(reporting_date) && DateDiff(contact_date, Date (reporting_date), 'days') <=2, "Contact Made 1",
DateDiff(citation_date, Date(contact_date), 'days') >=3, "Over Due- Citation three days over Warning",
DateDiff(citation_date, Date(contact_date),'days') <=2, "Contact Made 2",
"Open")
Thank you! I didn't know how to add code to the display. Yes I was showing my test of the script so people knew what I had already tried. The dates I expect to see are: clean up, reporting, contact, citation. They all have date fields to pull from. I have been testing it but symbology just wasn't showing. This is my first time trying to use Arcade (any code) to make symbology changes. So the help is very appreciated. Your example lead me to the right place to get it working.
This is what I have gotten the script to. It is not pretty but it seems to be working.
When(!IsEmpty($feature.clean_up_date),"Removed", //symbol changes to green when date field is not null (closed condition)
!IsEmpty($feature.removal_date),"Tow", //symbol changes to orange when date field is not null
!IsEmpty($feature.reporting_date) && IsEmpty($feature.contact_date) && IsEmpty($feature.citation_date) && IsEmpty($feature.clean_up_date) && DateDiff (Now(), Date ($feature.reporting_date), 'days') >=3, "Over Due- 3 days since Reported", //symbol changes to black/overdue when reporting date is 3 days over and contact, citation, or clean up date fields have no entry
!IsEmpty($feature.contact_date) && IsEmpty($feature.citation_date) && IsEmpty($feature.clean_up_date) && DateDiff (Now(), Date ($feature.contact_date), 'days') >=3, "Over Due- 3 days since Warning", //symbol changes to blue/overdue when contact date is 3 days over and citation or clean up date not entered
!IsEmpty($feature.citation_date) && IsEmpty($feature.clean_up_date) && DateDiff (Now(), Date ($feature.citation_date), 'days') >=3, "Over Due- 3 days since Citation", //symbol changes to Purple/overdue when citation date is 3 days over and clean up date not entered
!IsEmpty($feature.reporting_date) && DateDiff($feature.contact_date, Date ($feature.reporting_date), 'days') <=2, "Contact Made", //symbol changes to yellow/contact made when contact date is under three days from reporting date. Both fields have entry
"Open")//symbol changes to red/open when all other conditions are not meet