Select to view content in your preferred language

Arcade Expression (Logic - Required)

1113
10
Jump to solution
04-11-2024 04:25 AM
AidosMalybayev
Occasional Contributor

Hi, 

I'm new to arcade and trying write a simple expression to put logic requirement in a field.

I have three string fields (field1, field2, field3) with domains values (value1, value2).

If in field1 and field2 a specific values and their combination are chosen, field3 must NOT be required for filling if at least one condition match.

I tried but it does not work. Please advise what's incorrect

DomainName($feature,"Field1")!="Value1"||

DomainName($feature,"Field1")!="Value2"||

DomainName($feature,"Field1")!="Value3"&& DomainName($feature,"Field2")!="Value1"

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
KerriRasmussen
Esri Contributor
If(DomainName($feature, "Lithology") == "Tuff"){
    return false;
  }
  else if(DomainName($feature, "Lithology") == "Silica Rock" && DomainName($feature, "Protolithology") == "Tuff"){
  return false;
  }
  else if(!IsEmpty($feature["Lithology"])){
  return true;
  }
else {
  return false;
}

View solution in original post

10 Replies
KerriRasmussen
Esri Contributor

Good morning,

One suggestion I have for you is flipping your expression to the positive, meaning you will want to give the case(s) for when the field should show as required, instead of when it's not required. And when you do that you will want to use == when setting the fields equal, for example - 

DomainName($feature, "Modify_Date") == "Yes" 

 It's much easier to work in the positive with Arcade. 

Kerri

RPGIS
by
Frequent Contributor

Another option that works as well is using contingent values. This will automatically limit values based on inputs of other values.

jcarlson
MVP Esteemed Contributor

The phrase "at least one" sounds like the function Any. Put your conditions in an array, then use Any to return a true/false value if anything comes back.

Any([
  DomainName($feature,"Field1") != "Value1",
  DomainName($feature,"Field1") != "Value2",
  DomainName($feature,"Field1") != "Value3" && DomainName($feature,"Field2") != "Value1"
])
- Josh Carlson
Kendall County GIS
RPGIS
by
Frequent Contributor

The Includes function or a for loop I believe could also work as well. Plenty of options for achieving similar results.

AidosMalybayev
Occasional Contributor

There is an error:

Test execution error: Execution error - Call with wrong number of parameters. Verify test data.

0 Kudos
KerriRasmussen
Esri Contributor

Good morning. Would you mind sharing your Arcade Expression? It's easier to troubleshoot that way.

AidosMalybayev
Occasional Contributor

Good day,

Apologies for delaying with response.

There are three fields:

  • Lithology (Lith) - domain list with more than 30 values with two specific ones interesting for us - "Silica Rock" and "Tuff"
  • Protolithology (Protolith) - domain list with more than 30 values with specific one interesting for us - "Tuff"
  • Lithology Texture (Lith_text)  - domain list with more than 10 values

 

Lithology Texture field required when:

  • Lithology not empty

 

Lithology Texture field NOT required when:

  • Lithology = "Tuff"
  • Lithology = "Silica Rock" AND Protolithology = "Tuff"

 

My expression:

1 DomainName($feature,"Lith")!=null||

2 DomainName($feature,"Lith")!="Tuff"||

3 DomainName($feature,"Lith")!="Silica rock"&& DomainName($feature,"Protolith")!="Tuff"

 

It works with first line only.

Two others are not working i.e. Lithology Texture field with asterix (still required)

P.S. Expression 

Any([
DomainName($feature,"Lith_1")!=null,
DomainName($feature,"Lith_1")!="Tuff",
DomainName($feature,"Lith_1")!="Silica rock"&&DomainName($feature,"Protolith1")!="Tuff"
])
return: Test execution error: Execution error - Call with wrong number of parameters. Verify test data.
0 Kudos
KerriRasmussen
Esri Contributor
If(DomainName($feature, "Lithology") == "Tuff"){
    return false;
  }
  else if(DomainName($feature, "Lithology") == "Silica Rock" && DomainName($feature, "Protolithology") == "Tuff"){
  return false;
  }
  else if(!IsEmpty($feature["Lithology"])){
  return true;
  }
else {
  return false;
}
AidosMalybayev
Occasional Contributor

Thanks @KerriRasmussen !

0 Kudos