Select to view content in your preferred language

Arcade IF statement Returns False result in ArcGIS-Pro Pop-up

93
2
yesterday
nKuhan
by
New Contributor

Hello All,

When a point feature with Object ID 299 is selected, two other records from the same attribute table should be retrieved and displayed in a pop-up as a secondary table on the same Pop-up. (ArcGIS Pro). I am employing the if statement Arcade Expression, but it returns false. 

The following is a screenshot of the code and embedding of the expression into HTML for display in the pop-up. This is the code I am using.
 
Any tips?
 
Thanks
 
if($feature.OBJECTID==299){
return $feature.OBJECTID==297 && $feature.OBJECTID==300 && $feature.USER_C_UNI_VLAN_ID
}
0 Kudos
2 Replies
jcarlson
MVP Esteemed Contributor

I wish it were that easy! To retrieve the attributes of other features, you'll need to use some other functions.

In your expression, calling "$feature.OBJECTID" is going to return the object ID of the current feature.

The expression "$feature.OBJECTID==297" is what's called a "truthy" statement, in that it can be answered "true" or "false". If the clicked feature had the object ID of 297, that will return "true".

So, since you're chaining together multiple such statements with an "&&", Arcade is evaluating the statements as one large boolean. Since a given feature can only have a single object ID, asking it to return the output of "$feature.OBJECTID==297 && $feature.OBJECTID==300" will always be false, because you can't have one of those true without the other being false.

Take a look at the FeatureSetByName and Filter functions. You can use those to selectively return specific features and then access their individual attributes.

- Josh Carlson
Kendall County GIS
0 Kudos
KenBuja
MVP Esteemed Contributor

This return statement will not give you the information you desire. The logical operator (&&) in the return can only return a true or false. In the if statement, you're checking whether the OBJECTID of the feature is 299. Since that is true, the conditions ($feature.OBJECTID==297) in the return will both be false.

You also cannot use the logical operator with a statement that doesn't return a "True" or "False" (I'm assuming $feature.USER_C_UNI_VLAN_ID is the "VLAN ID" in your table).

If I'm understanding what you're trying to do, you should add in two additional Arcade field elements to your popup for the other two records. The code would look something like this

var feat = First(Filter($layer, "OBJECTID = 297"));
return {
  type: "fields",
  title: `Record ${feat.OBJECTID}`,
  fieldInfos: [
    { fieldName: "Service Type" },
    { fieldName: "Service Medium" },
    { fieldName: "VLAND ID" }
  ],
  attributes:
    {
      "Service Type": feat["Service_Type"],
      "Service Medium": feat["Service_Medium"],
      "VLAND ID": feat["USER_C_UNI_VLAN_ID"]
    }
};