generate alerts with date fields in Arcade for Arcgis

198
3
Jump to solution
07-10-2019 02:41 AM
BazileGagre
New Contributor

Hello,


I have created an intervention management application on a sanitation network with the webappbuilder. I would like to generate alerts regarding the dates of completion of the work with Arcade for ArcGIS.
Someone knows how to create an Arcade script to generate alerts with different colors from the start date of the work and the maximum completion date.

Thanking you in advance!

0 Kudos
1 Solution

Accepted Solutions
BazileGagre
New Contributor
0 Kudos
3 Replies
XanderBakker
Esri Esteemed Contributor

Hi Bazile Gagre ,

If your due date is an attribute of your features, you can base your symbology on the difference between the due date and the current date. You should probably include the completion date or status too in order to handle those assignments that have been completed.

Your expression could look something like this:

// make sure you point to the correct fields
var dueDate = $feature.dueDate;
var completedDate = $feature.completedDate;

var result = "";
if (!IsEmpty(completedDate)) {
    // task is not completed yet
    result = "completed";
} else {
    // task is not completed yet, determine days to due date
    var daysDif = DateDiff(dueDate, Today(), "days");
    Console(daysDif);
    // classify time to due date
    if (daysDif >= 3) {
        result = "more than 3 days to due date";
    } else if (daysDif > 1) {
        result = "only " + daysDif + " day(s) to due date"
    } else if (daysDif == 1) {
        result = "only 1 day to due date"
    } else if (daysDif == 0) {
        result = "due date is today!"
    } else {
        result = "Due date has passed!"
    }
}

return result;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
BazileGagre
New Contributor

Thank you

0 Kudos
XanderBakker
Esri Esteemed Contributor

You're welcome gagbaz . However, you marked you own answer with "Thank you" as the correct answer. The idea is that other users can find the correct answer easier, so maybe you can correct that?

0 Kudos