<?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: Form Calculation with $originalFeature return error &amp;quot;Unexpected Null Value&amp;quot; in ArcGIS Field Maps Questions</title>
    <link>https://community.esri.com/t5/arcgis-field-maps-questions/form-calculation-with-originalfeature-return-error/m-p/1217873#M4611</link>
    <description>&lt;P&gt;Good idea.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the error is gone (at least it never makes to the line providing the error), but no matter the change to the form it always returns self... which is a null service date.&lt;BR /&gt;&lt;BR /&gt;So $originalFeature == Null continues to evaluate to True.&lt;/P&gt;</description>
    <pubDate>Fri, 30 Sep 2022 13:31:41 GMT</pubDate>
    <dc:creator>JustinReynolds</dc:creator>
    <dc:date>2022-09-30T13:31:41Z</dc:date>
    <item>
      <title>Form Calculation with $originalFeature return error "Unexpected Null Value"</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/form-calculation-with-originalfeature-return-error/m-p/1217697#M4607</link>
      <description>&lt;P&gt;I'm attempting to us $originalFeature as a means to bail early on my more costly form field calculations.&amp;nbsp; The error feels like a bug rather than a limitation, but perhaps I'm missing something.&lt;BR /&gt;&lt;BR /&gt;Everything executes fine in the FM Arcade Editor, but FM throws the error "Unexpected Null Value" on points out the line that contains a reference to $originalFeature (line 4). This is present on both iOS &amp;amp; Android.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//expr_service_date
console('Calculating Service Date based on Service Number...');

var oServiceNumber = $originalFeature["service_number"];
var cServiceNumber = $feature["service_number"];
var self = $feature["service_date"];

//Test Values
// var oServiceNumber = "'02081600.1658 (20220811)";
// var cServiceNumber = "'02081600.1659 (20220812)";

// Exit Early - return self
if (oServiceNumber == cServiceNumber) {
    // if the service number didn't change return current value
    console('&amp;gt;&amp;gt;&amp;gt; No change detected, returning self');
    console('   &amp;gt;&amp;gt;&amp;gt; ' + self);
    return self;
};

// Do the costly things here only if a change is detected&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;@Anonymous User&amp;nbsp;Any thought?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2022 02:03:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/form-calculation-with-originalfeature-return-error/m-p/1217697#M4607</guid>
      <dc:creator>JustinReynolds</dc:creator>
      <dc:date>2022-09-30T02:03:59Z</dc:date>
    </item>
    <item>
      <title>Re: Form Calculation with $originalFeature return error "Unexpected Null Value"</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/form-calculation-with-originalfeature-return-error/m-p/1217760#M4608</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var self = $feature["service_date"];
if($originalFeature == null) {
    return self
}
var oServiceNumber = $originalFeature["service_number"];
var cServiceNumber = $feature["service_number"];&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 30 Sep 2022 07:00:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/form-calculation-with-originalfeature-return-error/m-p/1217760#M4608</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-09-30T07:00:48Z</dc:date>
    </item>
    <item>
      <title>Re: Form Calculation with $originalFeature return error "Unexpected Null Value"</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/form-calculation-with-originalfeature-return-error/m-p/1217873#M4611</link>
      <description>&lt;P&gt;Good idea.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the error is gone (at least it never makes to the line providing the error), but no matter the change to the form it always returns self... which is a null service date.&lt;BR /&gt;&lt;BR /&gt;So $originalFeature == Null continues to evaluate to True.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2022 13:31:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/form-calculation-with-originalfeature-return-error/m-p/1217873#M4611</guid>
      <dc:creator>JustinReynolds</dc:creator>
      <dc:date>2022-09-30T13:31:41Z</dc:date>
    </item>
    <item>
      <title>Re: Form Calculation with $originalFeature return error "Unexpected Null Value"</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/form-calculation-with-originalfeature-return-error/m-p/1217888#M4612</link>
      <description>&lt;P&gt;Okay so things work better when the edit type is UPDATE.&amp;nbsp; After some testing it appears that the state $originalFeature is not dynamic within your form (state doesn't keep up with your changes), but rather it is literally the $originalFeature.&amp;nbsp; On UPDATE, $originalFeature is not null and has a state (the state as last submitted), On INSERT, $originalFeature has no state or simply it is always null.&amp;nbsp; So you would want to combine the edit context edit type with your $originalFeature to prevent the endless circle or the error.&lt;BR /&gt;&lt;BR /&gt;Unfortunately, this doesn't provide the utility I was hoping for.&amp;nbsp; We would need something that preserves the state of each field (prior to a change) dynamically WHILE editing the form rather than just the state as last submitted.&lt;/P&gt;&lt;P&gt;Given&lt;/P&gt;&lt;P&gt;$OriginalFeature -&amp;gt; The state as last submitted (not dynamic within an edit session)&lt;/P&gt;&lt;P&gt;$Feature -&amp;gt; The current state (dynamic within an edit session)&lt;/P&gt;&lt;P&gt;we would need something like&lt;/P&gt;&lt;P&gt;$formerFeature or $exFeature or $previousFeature -&amp;gt; The previous state (dynamic with an edit session)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2022 14:29:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/form-calculation-with-originalfeature-return-error/m-p/1217888#M4612</guid>
      <dc:creator>JustinReynolds</dc:creator>
      <dc:date>2022-09-30T14:29:15Z</dc:date>
    </item>
  </channel>
</rss>

