<?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 question- Different editable settings for create/update features in ArcGIS Field Maps Questions</title>
    <link>https://community.esri.com/t5/arcgis-field-maps-questions/form-question-different-editable-settings-for/m-p/1281366#M5812</link>
    <description>&lt;P&gt;If you don't have a field calculation to deal with it is fairly simple.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Create a editable expression that examines the edit context profile variable:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/arcade/profiles/form-constraint/" target="_blank" rel="noopener"&gt;Arcade Constraint Profile Documentation&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://doc.arcgis.com/en/field-maps/android/help/configure-the-form.htm#ESRI_SECTION2_476F159685E14964BFEBC6F67F700020:~:text=Add%20editable%20expressions" target="_blank" rel="noopener"&gt;Create Editable Expression Documentation&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// prevent editing if this is an update, else allow editing
if ($editcontext.editType == 'UPDATE') {return false};
return true&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If you have a field calculation on the same field and you wish to preserve the value as calculated on INSERT you'll need to be more creative to stop the calculation from updating its value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this case, all the work is done in calculate expression rather than the editable expression since on INSERT or UPDATE the field is not editable. On UPDATE we need to preserve the value calculated on INSERT.&lt;BR /&gt;&lt;BR /&gt;It would look something like the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// This example calculation is occuring on field rsrc_previous_feature_info

function getOriginalSelf() {
    /* If state is UPDATE and the current service number hasn't changed return self 
       else return nothing. */

    if ($editcontext.editType == 'UPDATE') {        
        if (!IsEmpty($originalFeature)) {
            var oSelf = $originalFeature.rsrc_previous_feature_info;
            var oServiceNumber = $originalFeature.service_number;
            if (oServiceNumber == serviceNumber) {return oSelf};
        };
    };
};

var serviceNumber = $feature.service_number;

var originalSelf = getOriginalSelf();

/* if nothing is returned, then this is an INSERT, else 
exit early by returning the original value here */
if (!IsEmpty(originalSelf)) {return originalSelf}; 

// continue the calculation for an INSERT below...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 21 Apr 2023 17:05:06 GMT</pubDate>
    <dc:creator>JustinReynolds</dc:creator>
    <dc:date>2023-04-21T17:05:06Z</dc:date>
    <item>
      <title>Form question- Different editable settings for create/update features</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/form-question-different-editable-settings-for/m-p/1281317#M5811</link>
      <description>&lt;P&gt;I have a form used for adding new sites to our hosted feature layer. I'd like to make some of the attributes read only if the user is editing an existing site, but make them all editable if the user is creating a new site. Any suggestions on how to set this up?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 15:28:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/form-question-different-editable-settings-for/m-p/1281317#M5811</guid>
      <dc:creator>Strahanjen</dc:creator>
      <dc:date>2023-04-21T15:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: Form question- Different editable settings for create/update features</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/form-question-different-editable-settings-for/m-p/1281366#M5812</link>
      <description>&lt;P&gt;If you don't have a field calculation to deal with it is fairly simple.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Create a editable expression that examines the edit context profile variable:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/arcade/profiles/form-constraint/" target="_blank" rel="noopener"&gt;Arcade Constraint Profile Documentation&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://doc.arcgis.com/en/field-maps/android/help/configure-the-form.htm#ESRI_SECTION2_476F159685E14964BFEBC6F67F700020:~:text=Add%20editable%20expressions" target="_blank" rel="noopener"&gt;Create Editable Expression Documentation&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// prevent editing if this is an update, else allow editing
if ($editcontext.editType == 'UPDATE') {return false};
return true&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If you have a field calculation on the same field and you wish to preserve the value as calculated on INSERT you'll need to be more creative to stop the calculation from updating its value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this case, all the work is done in calculate expression rather than the editable expression since on INSERT or UPDATE the field is not editable. On UPDATE we need to preserve the value calculated on INSERT.&lt;BR /&gt;&lt;BR /&gt;It would look something like the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// This example calculation is occuring on field rsrc_previous_feature_info

function getOriginalSelf() {
    /* If state is UPDATE and the current service number hasn't changed return self 
       else return nothing. */

    if ($editcontext.editType == 'UPDATE') {        
        if (!IsEmpty($originalFeature)) {
            var oSelf = $originalFeature.rsrc_previous_feature_info;
            var oServiceNumber = $originalFeature.service_number;
            if (oServiceNumber == serviceNumber) {return oSelf};
        };
    };
};

var serviceNumber = $feature.service_number;

var originalSelf = getOriginalSelf();

/* if nothing is returned, then this is an INSERT, else 
exit early by returning the original value here */
if (!IsEmpty(originalSelf)) {return originalSelf}; 

// continue the calculation for an INSERT below...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 17:05:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/form-question-different-editable-settings-for/m-p/1281366#M5812</guid>
      <dc:creator>JustinReynolds</dc:creator>
      <dc:date>2023-04-21T17:05:06Z</dc:date>
    </item>
  </channel>
</rss>

