<?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: Arcade expression that changes fields to Null after copying and pasting feature. in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-expression-that-changes-fields-to-null/m-p/1549971#M89270</link>
    <description>&lt;P&gt;Thank you &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/215483"&gt;@VinceE&lt;/a&gt;.&amp;nbsp; Your code worked as expected.&amp;nbsp; Much appreciated.&lt;/P&gt;</description>
    <pubDate>Fri, 18 Oct 2024 15:45:37 GMT</pubDate>
    <dc:creator>GIS_geek</dc:creator>
    <dc:date>2024-10-18T15:45:37Z</dc:date>
    <item>
      <title>Arcade expression that changes fields to Null after copying and pasting feature.</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-expression-that-changes-fields-to-null/m-p/1546703#M88993</link>
      <description>&lt;P&gt;Looking for some help with an Arcade expression to use as an Attribute Rule.&amp;nbsp; Sometimes we copy and paste features within and/or different feature class and need a few fields that have records to show as Null in the new feature.&amp;nbsp; I came up with the following expression, which verifies as valid but returns an error code when I copy/paste the feature.&amp;nbsp; I have Insert trigger checked.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Set fields to null if they have values
if (!IsEmpty("M_AssetNum") || !IsEmpty("M_InstallYear") || !IsEmpty("M_Material")) {
    return {
        "M_AssetNum": Null,
        "M_InstallYear": Null,
        "M_Material": Null
    };
}

// If the fields are already empty, do nothing
return {};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the error message it returns after trying to paste.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Rule Error.JPG" style="width: 380px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/116773iE3E167134CD9805E/image-size/large?v=v2&amp;amp;px=999" role="button" title="Rule Error.JPG" alt="Rule Error.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2024 19:14:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-expression-that-changes-fields-to-null/m-p/1546703#M88993</guid>
      <dc:creator>GIS_geek</dc:creator>
      <dc:date>2024-10-08T19:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression that changes fields to Null after copying and pasting feature.</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-expression-that-changes-fields-to-null/m-p/1546780#M88998</link>
      <description>&lt;P&gt;Your code is not checking if the VALUES in those fields are not empty, your code is checking if those specific strings/text values are not empty. It would be like writing !IsEmpty("here is a big long text string").&lt;/P&gt;&lt;P&gt;You want to be checking "$feature.M_InstallYear", where "$feature" is a token representing the row (or a subset thereof, depending), and you're asking for the value that is in the M_InstallYear field.&lt;/P&gt;&lt;P&gt;Also, you're trying to return three results, so you need to specify those fields in your return results dictionary, I believe.&lt;/P&gt;&lt;P&gt;You also don't need to return the blank brackets. Just don't return anything if you don't need to perform a calculation. Alternatively, you could just always set these three values to NULL, without even doing the "if" statement. I can't imagine you're saving that much processing overhead by checking if you need to first, but someone else might know more about that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Specifically list fields to be used in this AR.
// Not always clear on when this is necessary (don't think it is here), but useful to know about.
Expects($feature, "M_AssetNum", "M_InstallYear", "M_Material")

if (!IsEmpty($feature.M_AssetNum) || !IsEmpty($feature.M_InstallYear) || !IsEmpty($feature.M_Material)) {
    return {
        "result": {
            "attributes": {
                "M_AssetNum": null, 
                "M_InstallYear": null,
                "M_Material": null
            }
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2024 23:37:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-expression-that-changes-fields-to-null/m-p/1546780#M88998</guid>
      <dc:creator>VinceE</dc:creator>
      <dc:date>2024-10-08T23:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression that changes fields to Null after copying and pasting feature.</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-expression-that-changes-fields-to-null/m-p/1549971#M89270</link>
      <description>&lt;P&gt;Thank you &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/215483"&gt;@VinceE&lt;/a&gt;.&amp;nbsp; Your code worked as expected.&amp;nbsp; Much appreciated.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Oct 2024 15:45:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-expression-that-changes-fields-to-null/m-p/1549971#M89270</guid>
      <dc:creator>GIS_geek</dc:creator>
      <dc:date>2024-10-18T15:45:37Z</dc:date>
    </item>
  </channel>
</rss>

