Using Arcade to Set Up Clean Schedule

11-13-2019 03:29 PM
New Contributor


I am trying to set up a collector app for infrastructure cleaning schedules. I have it set up to automatically add a date when a new point is added representing a cleaned line. Now I am trying to set up an arcade script that will take this last cleaned date and calculate the next cleaning date, then use that to symbolize lines now needing to be cleaned.

There are several cleaning schedule categories (1 month, 3 months, 2 years, etc), so the script would need to look at the cleaning schedule field, and then calculate the new cleaning date accordingly. I'm assuming the best workflow for this would be to use arcade functions in order to do;

   -  select group by cleaning schedule

      - calculate next clean date by taking last clean date + clean schedule

       - set status to "clean required" when new clean date is reached

I know to use the DateAdd function to calculate the new date, but I am unsure how to link selecting the date field by clean schedule as I am new to arcade. Thanks in advance for any advice on the subject. 

0 Kudos
2 Replies
Esri Regular Contributor

Hi Magdalena Martinez‌,

I think you would want to use an if/else statement to find features with a specific cleaning schedule. This might look something like this:

//set global variables

var Schedule = $feature.Schedule
var DateField = $feature.EditDate
var currentDay = today()

//begin conditional statements

if (Schedule == 'One Month') {
Var MonthPickup = DateAdd(DateField, 1, 'months')
var MonthDifference = DateDiff(MonthPickup, currentDay, 'days')
Var MonthDisplay = iif (MonthDifference > 0, 'No Clean Required','Clean Required');
return MonthDisplay

else if (Schedule == "Three Months") {
Var ThreeMonthPickup = DateAdd(DateField, 2 , 'months')
var ThreeMonthDifference = DateDiff(ThreeMonthPickup, currentDay, 'days')
Var ThreeMonthDisplay = iif (ThreeMonthDifference > 0, 'No Clean Required','Clean Required');
return ThreeMonthDisplay

else if (Schedule == "Two Years") {
Var TwoYearPickup = DateAdd(DateField, 2 , 'years')
var TwoYearDifference = DateDiff(TwoYearPickup, currentDay, 'days')
Var TwoYearDisplay = iif (TwoYearDifference > 0, 'No Clean Required','Clean Required');
return TwoYearDisplay

else {
return "No Data Available"

There is also an ArcGIS Solution Template with a much more sophisticated pick-up schedule Arcade script that you might be interested in: My Trash Services | ArcGIS Solutions for Local Government 

Hope this helps ~


Esri Esteemed Contributor

Hi mmartinez_cityofarcata ,

I have published a couple of documents related to this (unfortunately in Spanish, but you should be able to use the URL in Google Translate and get a translated page):

A live sample from a client can be found here: 

If you have any questions, I'll be happy to help you.

0 Kudos