Domains in Arcade

7142
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
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

You have to enclose any string values in quotes. You could either use "if/else" or the IIF function to also return values that don't meet your criteria.

if (DomainName($feature,'WA') == '8/10/2020 - 8/16/2020' && DomainName($feature,'InSta') == 'To Be Installed') {
    return 'Needs to Be Installed';
} else {
    return "Didn't meet criteria";
}

or

iif(DomainName($feature,'WA') == '8/10/2020 - 8/16/2020' && DomainName($feature,'InSta') == 'To Be Installed', 'Needs to Be Installed', "Didn't meet criteria");

View solution in original post

0 Kudos
14 Replies
KenBuja
MVP Esteemed Contributor

Are the domain values for "WA" strings? If so, your syntax is incorrect

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

Otherwise, what are the values?

0 Kudos
NWEdisonTeam
New Contributor II

The domains are indeed strings. It is not a Date type column. Also the " " around "WA" should be ' '. Apologies.

0 Kudos
KenBuja
MVP Esteemed Contributor

Does adding the quotes around the date range help or are you still getting unexpected results?

0 Kudos
NWEdisonTeam
New Contributor II

Taking the quotes away on the date range makes it turn blue, which I am assuming is the code recognizing the Domain code/name. Removing the quotes from the 'To Be Installed' seems to nullify the expression and create an error. Otherwise, the expression will return no values which is wrong. 

0 Kudos
KenBuja
MVP Esteemed Contributor

If I understand what you're saying, the colors change if the text is a string value (red), a function or number (blue), or part of the Javascript syntax (black). It isn't doing any compiling to recognize domain values. Are you able to supply screen shots of your expression and the data?

For example, here is one of the scripts I have that uses fields with domains. I'm not using the DomainName function, but just working with the codes. The field "Benthic Status" has three possible codes. If I click on the pencil icon for that field, it shows the codes and their names.

0 Kudos
NWEdisonTeam
New Contributor II

So in my code it is not recognizing that  'To Be Installed' Is a Code

0 Kudos
KenBuja
MVP Esteemed Contributor

You have to enclose any string values in quotes. You could either use "if/else" or the IIF function to also return values that don't meet your criteria.

if (DomainName($feature,'WA') == '8/10/2020 - 8/16/2020' && DomainName($feature,'InSta') == 'To Be Installed') {
    return 'Needs to Be Installed';
} else {
    return "Didn't meet criteria";
}

or

iif(DomainName($feature,'WA') == '8/10/2020 - 8/16/2020' && DomainName($feature,'InSta') == 'To Be Installed', 'Needs to Be Installed', "Didn't meet criteria");
0 Kudos
NWEdisonTeam
New Contributor II

That got it. Thanks you!

0 Kudos
NWEdisonTeam
New Contributor II

I noticed you used single quotes over the $feature,'Insta' and $Feature,'WA' vs my double quotes. Was that the issue?

0 Kudos