<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: 'Unexpected Null' error in Attribute Rule Validation in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/unexpected-null-error-in-attribute-rule-validation/m-p/1299157#M70219</link>
    <description>&lt;P&gt;Hey, that worked. Thank you &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt;&amp;nbsp;for the help!!&lt;/P&gt;&lt;P&gt;I now see how that error was happening--I had forgotten to account for the sample validation record not having a match and therefore returning an empty filter. I didn't think to check the filter itself as well as the field value.&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;-Greg&lt;/P&gt;</description>
    <pubDate>Wed, 14 Jun 2023 14:09:29 GMT</pubDate>
    <dc:creator>GregoryWhitaker</dc:creator>
    <dc:date>2023-06-14T14:09:29Z</dc:date>
    <item>
      <title>'Unexpected Null' error in Attribute Rule Validation</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/unexpected-null-error-in-attribute-rule-validation/m-p/1298902#M70192</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm currently building an immediate calculation (update) attribute rule in ArcGIS Pro (2.9x) that basically copies the updated row to a different feature class and adds a few attributes to the copied row from various other tables in the $datastore. I'm still somewhat new to arcade.&lt;/P&gt;&lt;P&gt;One of the table values that I need to grab and insert is not guaranteed to be populated, so I have accounted for this by using an IsEmpty condition before setting the field values to a variable.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue I'm having is that, the arcade editor box will not allow me to save and apply the code because the random(?) row that it's pulling to do the syntax validation had a null value before I added the null check. I added a conditional null check afterwards realizing that I had forgotten to do so, but it still does the same. As a last resort, just to get the rule saved, I calculated out any null values in the field of concern, also to no avail. It almost seems like pro is caching values somewhere or the validation is stuck, but I've cleared the project cache, created a new project, and re-added all the layers, so I don't think that is it.&lt;/P&gt;&lt;P&gt;Code is below. The offender is ggsFilter.GGS . I have also tried == null as well as the DefaultValue() commented out below it. Also probably worth noting that all the field values are coming in with the ggsFilter, so it's not that there's an empty object.&lt;/P&gt;&lt;P&gt;Any pointers or ideas would be greatly appreciated! Thanks in advance!&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 395px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/73128iA569F03C7EDF5A9A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var geom = Geometry($feature);

//COMPANY TABLE
var companyFc = FeatureSetByName($datastore, "COMPANY", ["UNIQUE_ID", "COMPANY_NAME", "IS_OPERATOR"], false);
var companyFilter = First(Filter(companyFc, "UNIQUE_ID = '" + $feature.COMPANY_ID + "'"));

//GGS_DISTRICT
var ggsFc = FeatureSetByName($datastore, "PODS_GGS_DISTRICT", ["UNIQUE_ID", "STANDARD_NAME", "GGS", "FIELD_OFFICE"], false);
var ggsFilter = First(Filter(ggsFc, "UNIQUE_ID = '" + $feature.GGS_DISTRICT_ID + "'"));

if (IsEmpty(ggsFilter.GGS)) {
    var ggsName = 'GGS data is null';
    var ggsNumber = 'GGS data is null';
} else {
    var ggsText = Split(Trim(ggsFilter.GGS), ' - ');
    var ggsName = ggsText[0];
    var ggsNumber = ggsText[1];
}
// var ggsName = DefaultValue(Split(Trim(ggsFilter.GGS), ' - ')[0], 'GGS data is null');
// var ggsNumber = DefaultValue(Split(Trim(ggsFilter.GGS), ' - ')[1], 'GGS data is null');

//OPERATING_AREA
var operatingAreaFc = FeatureSetByName($datastore, "PODS_OPERATING_AREA", ["STANDARD_NAME"]);
var operatingAreaIntersect = First(Intersects(operatingAreaFc, geom));

//OPERATING_GROUP
var operatingGroupFc = FeatureSetByName($datastore, "PODS_OPERATING_GROUP", ["STANDARD_NAME"]);
var operatingGroupIntersect = First(Intersects(operatingGroupFc, geom));

//FRANCHISE
var franchiseFc = FeatureSetByName($datastore, "PODS_FRANCHISE", ["STANDARD_NAME"]);
var franchiseIntersect = First(Intersects(franchiseFc, geom));

//DIVISION
var divisionFc = FeatureSetByName($datastore, "PODS_DIVISION", ["STANDARD_NAME"]);
var divisionIntersect = First(Intersects(divisionFc, geom));

if ($feature.EDIT_RESPONSE == 'Abandon') {
    var fieldMap = [
        { 
            "attributes": {
                //from StructureBoundary
                "COMMENTS": $feature.COMMENTS,
                "DESCRIPTION": $feature.DESCRIPTION,
                "SUBTYPE": $feature.SUBTYPE,
                "UNIQUE_TERM_ID": $feature.UNIQUE_TERM_ID,
                "SITE_NAME": $feature.SITE_NAME,
                "SITE_ID": $feature.SITE_ID,
                "BOUNDARY_TYPE": $feature.BOUNDARY_TYPE,
                "SOURCE": $feature.SOURCE,
                "NAME": $feature.NAME,
                "UNIQUE_ID": $feature.UNIQUE_ID,
                "WORKORDER": $feature.WORKORDER,
                "ACREAGE": $feature.ACREAGE,
                "COUNTY": $feature.COUNTY,
                "TRANSMISSION_FACILITY": $feature.TRANSMISSION_FACILITY,
                "HCA_DIAMETER": $feature.HCA_DIAMETER,
                "HCA_FACILITY": $feature.HCA_FACILITY,
                "BORN_ON_DATE": $feature.BORN_ON_DATE,
                "PROGRAM_NAME": $feature.PROGRAM_NAME,
                "PROJECT_NAME": $feature.PROJECT_NAME,
                "FERC_REGULATED": $feature.FERC_REGULATED,
                "OPERATOR_ID": $feature.OPERATOR_ID,
                "HCA_TYPE": $feature.HCA_TYPE,
                "PHYSICAL_STATE": $feature.STATE,
                //from COMPANY
                "COMPANY_NAME": companyFilter.COMPANY_NAME,
                "OPERATOR": companyFilter.IS_OPERATOR,
                //from OPERATING_AREA
                "OPERATING_AREA": operatingAreaIntersect.STANDARD_NAME,
                //from OPERATING_GROUP
                "OPERATING_GROUP": operatingGroupIntersect.STANDARD_NAME,
                //from FRANCHISE
                "FRANCHISE": franchiseIntersect.STANDARD_NAME,
                //from DIVISION
                "DIVISION": divisionIntersect.STANDARD_NAME,
                //from GGS_DISTRICT
                "DISTRICT_GGS": ggsFilter.STANDARD_NAME,
                "GGS_NAME": DefaultValue(Split(Trim(ggsFilter.GGS), ' - ')[0], 'GGS data is null'),
                "GGS_NUMBER": DefaultValue(Split(Trim(ggsFilter.GGS), ' - ')[1], 'GGS data is null'),
                "FIELD_OFFICE": ggsFilter.FIELD_OFFICE
            },
            "geometry": geom
        }
    ]

    return {
        "edit": [{
            "className": "Site_Abandoned",
            "adds": fieldMap
        }]  
    }
}
else if ($feature.EDIT_RESPONSE == 'Divest') {
    //TODO LATER
    var fieldMap = [
        { 
            "attributes": {
                "COMMENTS": $feature.COMMENTS,
                "DESCRIPTION": $feature.DESCRIPTION,
                "SUBTYPE": $feature.SUBTYPE,
                "UNIQUE_TERM_ID": $feature.UNIQUE_TERM_ID,
                "SITE_NAME": $feature.SITE_NAME,
                "SITE_ID": $feature.SITE_ID,
                "BOUNDARY_TYPE": $feature.BOUNDARY_TYPE,
                "SOURCE": $feature.SOURCE,
                "NAME": $feature.NAME,
                "UNIQUE_ID": $feature.UNIQUE_ID,
                "WORKORDER": $feature.WORKORDER,
                "ACREAGE": $feature.ACREAGE,
                "COUNTY": $feature.COUNTY,
                "OPERATIONAL_STATUS": $feature.OPERATIONAL_STATUS,
                "TRANSMISSION_FACILITY": $feature.TRANSMISSION_FACILITY,
                "HCA_DIAMETER": $feature.HCA_DIAMETER,
                "HCA_FACILITY": $feature.HCA_FACILITY,
                "BORN_ON_DATE": $feature.BORN_ON_DATE,
                "PROGRAM_NAME": $feature.PROGRAM_NAME,
                "PROJECT_NAME": $feature.PROJECT_NAME,
                "FERC_REGULATED": $feature.FERC_REGULATED,
                "OPERATOR_ID": $feature.OPERATOR_ID,
                "HCA_TYPE": $feature.HCA_TYPE,
                "PHYSICAL_STATE": $feature.STATE,

                "COMPANY_NAME": companyName,
                "OPERATOR": operator
            },
            "geometry": geom
        }
    ]

    return {
        "edit": [{
            "className": "Site_Divested",
            "adds": fieldMap
        }]  
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2023 20:44:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/unexpected-null-error-in-attribute-rule-validation/m-p/1298902#M70192</guid>
      <dc:creator>GregoryWhitaker</dc:creator>
      <dc:date>2023-06-13T20:44:14Z</dc:date>
    </item>
    <item>
      <title>Re: 'Unexpected Null' error in Attribute Rule Validation</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/unexpected-null-error-in-attribute-rule-validation/m-p/1299032#M70206</link>
      <description>&lt;P&gt;When you call First() on an empty Featureset, it will return null. You're trying to call an attribute of null, which raises the error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if (IsEmpty(ggsFilter) || IsEmpty(ggsFilter.GGS)) {
//...
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You're missing null checks in your return dictionaries, too. These might pass evaluation, but they will raise errors on execution if you encounter empty filtered Featuresets. An easy way to handle these would be IIf():&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if ($feature.EDIT_RESPONSE == 'Abandon') {
    var fieldMap = [
        { 
            "attributes": {
                //from StructureBoundary
                    // bla
                //from COMPANY
                "COMPANY_NAME": IIf(companyFilter == null, "Default Value", .COMPANY_NAME),
                "OPERATOR": IIf(companyFilter == null, "Default Value", companyFilter.IS_OPERATOR),&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2023 07:23:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/unexpected-null-error-in-attribute-rule-validation/m-p/1299032#M70206</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-06-14T07:23:33Z</dc:date>
    </item>
    <item>
      <title>Re: 'Unexpected Null' error in Attribute Rule Validation</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/unexpected-null-error-in-attribute-rule-validation/m-p/1299157#M70219</link>
      <description>&lt;P&gt;Hey, that worked. Thank you &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt;&amp;nbsp;for the help!!&lt;/P&gt;&lt;P&gt;I now see how that error was happening--I had forgotten to account for the sample validation record not having a match and therefore returning an empty filter. I didn't think to check the filter itself as well as the field value.&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;-Greg&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2023 14:09:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/unexpected-null-error-in-attribute-rule-validation/m-p/1299157#M70219</guid>
      <dc:creator>GregoryWhitaker</dc:creator>
      <dc:date>2023-06-14T14:09:29Z</dc:date>
    </item>
  </channel>
</rss>

