Select to view content in your preferred language

Arcade symbology based on date and field fills. Can't get to work.

1391
2
Jump to solution
11-03-2023 02:11 PM
Labels (3)
SRanseen
Occasional Contributor

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.

  • 😀Open: ( Reporting date is not null)
  • 😀Removed: (Clean up date is not null)
  • 😀Contact Made 1: (Reporting date is not null and Contact date is not null  and does not exceed 2 days from reporting date)
  • 😀Contact Made 2: ( Contact date is not null and Citation date is not null does not exceed 2 days from Contact date)
  • Over Due 1: three days have passed since reporting and no other dates have been filled
  • Over Due 2:  three days have passed since Contact date and no other dates have been filled
  • Over Due 3: three days have passed since citation and no other dates have been filled
  • 😀Over Due 4: Contact date is filled three days after report date filled
  • 😀Over Due 5: Citation date filled three days after Contact date filled
  • Towing:  if there has been no date fill over 24 hrs from citation day
0 Kudos
2 Solutions

Accepted Solutions
KenBuja
MVP Esteemed Contributor

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")

View solution in original post

SRanseen
Occasional Contributor

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

 

 

View solution in original post

0 Kudos
2 Replies
KenBuja
MVP Esteemed Contributor

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")
SRanseen
Occasional Contributor

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

 

 

0 Kudos