Domains in Arcade

7328
14
Jump to solution
08-11-2020 12:45 PM
NWEdisonTeam
New Contributor II

Hi

I am trying to parse out a conditional expression for visually displaying locations in Arcade (Arcgis Online) that contains two domains and I am either A, not getting the resultant I want, or B getting an error, depending on how I structure it.

 if (DomainName($feature,"WA") == 8/10/2020 - 8/16/2020 && DomainName($feature,"InSta") == 'To Be Installed') {Return 'Needs to Be Installed'}

This version returns null values. Any help would be appreciated!

Tags (1)
0 Kudos
14 Replies
KenBuja
MVP Esteemed Contributor

No, they are interchangeable. Notice I had to use double quotes in the else return since the string contained a single quote.

Something like this works fine (from the Playground), but you try to be consistent

iif($feature.LASTEDITOR == "Esri", 'Yes', "No")‍‍
NWEdisonTeam
New Contributor II

To Continue this, I am finding that the expanded code is not yielding the corresponding results. Any thoughts?


if (DomainName($feature,'InSta') == 'To Be Installed'){
if (DomainName($feature,'WA') == '8/10/2020 - 8/16/2020'){
return 'Priority 1 Install';
} else if (DomainName($feature,'WA') == '8/10/2020 - 8/16/2020'){
return 'Priority 2 Install';
} else if (DomainName($feature,'WA') == '8/24/2020 - 8/30/2020'){
return 'Priority 3 Install';
} else if (DomainName($feature,'WA') == '5/25/2020 - 5/31/2020'){
return 'Do Not Install'
} else {
return 'Installed';
}
}

0 Kudos
KenBuja
MVP Esteemed Contributor

One thing I notice is your first two date range if statements use the same range. What are you getting and what are you expecting? It is possible to see a snapshot of the data?

0 Kudos
NWEdisonTeam
New Contributor II

1. That code was wrong I mis-copied so apologies

2. I got it to work by changing the structure and just doing a bunch of else if clauses. See the screen shots below: 

I was overly complicating it

0 Kudos
AdamBakiera
Occasional Contributor

I am having a similar issue. Here is my code:

var days = DateDiff(Now(), $feature["Inspected_Date"], "days");

if (days > 60 && days < 180 && $feature["Inspection_Status"] == 'Repair Needed') {
return "This was inspected between 2 and 6 months ago - Repair Needed";
}

if (days > 180 && $feature["Inspection_Status"] == 'Repair Needed') {
return "This was inspected more than 6 months ago - Repair Needed";
}

if (days < 60 && $feature["Inspection_Status"] == 'Repair Needed') {
return "This was inspected in the past 2 months - Repair Needed";
}

if (days > 60 && days < 180 && $feature["Inspection_Status"] == 'Passed') {
return "This was inspected between 2 and 6 months ago - Passed";
}

if (days > 180 && $feature["Inspection_Status"] == 'Passed') {
return "This was inspected more than 6 months ago - Passed";
}

if (days < 60 && $feature["Inspection_Status"] == 'Passed') {
return "This was inspected in the past 2 months - Passed";
}

 

I know for a fact the days variable and that logic works because that's the way our application is set up right now. We are just wanting to add that inspection status element.

0 Kudos