<?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: how to set default values for editor widget esri 4 programmatically in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-set-default-values-for-editor-widget-esri-4/m-p/1211115#M78658</link>
    <description>&lt;P&gt;Default values can only be set when publishing the services. Adding default values via the Editor widget is not supported.&lt;/P&gt;</description>
    <pubDate>Fri, 09 Sep 2022 14:27:38 GMT</pubDate>
    <dc:creator>ReneRubalcava</dc:creator>
    <dc:date>2022-09-09T14:27:38Z</dc:date>
    <item>
      <title>how to set default values for editor widget esri 4 programmatically</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-set-default-values-for-editor-widget-esri-4/m-p/1211105#M78657</link>
      <description>&lt;P&gt;how to set default values for editor widget esri 4 programmatically&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Sep 2022 14:02:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-set-default-values-for-editor-widget-esri-4/m-p/1211105#M78657</guid>
      <dc:creator>karimkimo</dc:creator>
      <dc:date>2022-09-09T14:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: how to set default values for editor widget esri 4 programmatically</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-set-default-values-for-editor-widget-esri-4/m-p/1211115#M78658</link>
      <description>&lt;P&gt;Default values can only be set when publishing the services. Adding default values via the Editor widget is not supported.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Sep 2022 14:27:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-set-default-values-for-editor-widget-esri-4/m-p/1211115#M78658</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2022-09-09T14:27:38Z</dc:date>
    </item>
    <item>
      <title>Betreff: how to set default values for editor widget esri 4 programmatically</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-set-default-values-for-editor-widget-esri-4/m-p/1212300#M78704</link>
      <description>&lt;P data-unlink="true"&gt;Well, it is possible to prefill the FeatureForm by using the&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureForm-FeatureFormViewModel.html#setValue" target="_self"&gt;setValue&lt;/A&gt; method.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const editor = new Editor({
  view: view,
});

editor.watch("viewModel.featureFormViewModel.feature", () =&amp;gt; {
  editor.viewModel.featureFormViewModel.setValue("Description", "Test")
});&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;(In my example, "Description" is the name of the Field, "Test" the value)&lt;/P&gt;&lt;P&gt;At least that's my current approach. But I'm still struggling to limit this so it only prefills the field of newly created features and not when editing already existing features. Does anyone know how this could be implemented?&lt;/P&gt;&lt;P&gt;---&lt;/P&gt;&lt;P&gt;Edit: Some spaghetti code which seems to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const editor = new Editor({
  view: view,
});
editorVM = editor.viewModel;

editorVM.watch(['state', 'featureFormViewModel.feature'], () =&amp;gt; {
  if (editorVM.state == 'creating-features' &amp;amp;&amp;amp; editorVM.featureFormViewModel.feature !== 'undefined') {
    editorVM.featureFormViewModel.setValue("Description", "Test")
  }
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2023 12:50:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-set-default-values-for-editor-widget-esri-4/m-p/1212300#M78704</guid>
      <dc:creator>MatthiasKl</dc:creator>
      <dc:date>2023-02-27T12:50:18Z</dc:date>
    </item>
  </channel>
</rss>

