<?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 Validate Editor widget Edits Before Saving in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/validate-editor-widget-edits-before-saving/m-p/1412242#M84377</link>
    <description>&lt;P&gt;Good Day,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have added the Editor and it is working. However, i would like to validate the user inputs before it saves/updates/ commit. Please assist.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var editor = new Editor({ view: view, layerInfos: [editParcel], visibleElements: { snappingControls: false }, container: document.createElement("div") });&lt;/P&gt;&lt;P&gt;view.popup.on("trigger-action", function (event){ if (event.action.id === "edit-this") {selectFeature(view.popup.selectedFeature.attributes.fid); }&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;function selectFeature(num){&lt;BR /&gt;if (!editor.activeWorkFlow)&lt;BR /&gt;{&lt;BR /&gt;view.popup.visible = false;&amp;nbsp;&lt;BR /&gt;editFeature = view.popup.selectedFeature;&lt;BR /&gt;editor.startUpdateWorkflowAtFeatureEdit(view.popup.selectedFeature);&lt;BR /&gt;view.ui.add(editor, "top-right"); console.log("EDITOR ", editor);&lt;BR /&gt;}&lt;BR /&gt;reactiveUtils.when(() =&amp;gt; editor.viewModel.state === "ready", () =&amp;gt; { view.ui.remove(editor);&amp;nbsp; });&lt;BR /&gt;}//end function&lt;/P&gt;&lt;P&gt;// Watch when the popup is visible&lt;BR /&gt;reactiveUtils.watch(() =&amp;gt; view.popup?.visible, (event) =&amp;gt; { if (editor.viewModel.state === "editing-existing-feature") { view.closePopup(); } else { features = view.popup.features; } });&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/////////// MY ATTEMPT -&amp;gt; UNSUCCESSFUL;;&amp;nbsp; DATA STILL UPDATED&lt;/P&gt;&lt;P&gt;parcelLayer.on("apply-edits", (event) =&amp;gt;&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;const validd = validData(editFeature.attributes);&lt;/P&gt;&lt;P&gt;if (validd == false) { return;}&lt;/P&gt;&lt;P&gt;else&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;view.ui.remove(editor);&lt;BR /&gt;// Iterate through the features&lt;BR /&gt;features.forEach((feature) =&amp;gt; {&lt;BR /&gt;// Reset the template for the feature if it was edited&lt;BR /&gt;feature.popupTemplate = editablelPopup;&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;// Open the popup again and reset its content after updates were made on the feature&lt;BR /&gt;&amp;nbsp;if (features) {&amp;nbsp;view.popup.open({&amp;nbsp;features: features&amp;nbsp;});&amp;nbsp;}&lt;/P&gt;&lt;P&gt;//Cancel the workflow so that once edits are applied, a new popup can be displayed&lt;BR /&gt;editor.viewModel.cancelWorkflow();&lt;/P&gt;&lt;P&gt;}//end else&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;});&lt;/P&gt;</description>
    <pubDate>Fri, 19 Apr 2024 13:06:10 GMT</pubDate>
    <dc:creator>RichardRhone1</dc:creator>
    <dc:date>2024-04-19T13:06:10Z</dc:date>
    <item>
      <title>Validate Editor widget Edits Before Saving</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/validate-editor-widget-edits-before-saving/m-p/1412242#M84377</link>
      <description>&lt;P&gt;Good Day,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have added the Editor and it is working. However, i would like to validate the user inputs before it saves/updates/ commit. Please assist.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var editor = new Editor({ view: view, layerInfos: [editParcel], visibleElements: { snappingControls: false }, container: document.createElement("div") });&lt;/P&gt;&lt;P&gt;view.popup.on("trigger-action", function (event){ if (event.action.id === "edit-this") {selectFeature(view.popup.selectedFeature.attributes.fid); }&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;function selectFeature(num){&lt;BR /&gt;if (!editor.activeWorkFlow)&lt;BR /&gt;{&lt;BR /&gt;view.popup.visible = false;&amp;nbsp;&lt;BR /&gt;editFeature = view.popup.selectedFeature;&lt;BR /&gt;editor.startUpdateWorkflowAtFeatureEdit(view.popup.selectedFeature);&lt;BR /&gt;view.ui.add(editor, "top-right"); console.log("EDITOR ", editor);&lt;BR /&gt;}&lt;BR /&gt;reactiveUtils.when(() =&amp;gt; editor.viewModel.state === "ready", () =&amp;gt; { view.ui.remove(editor);&amp;nbsp; });&lt;BR /&gt;}//end function&lt;/P&gt;&lt;P&gt;// Watch when the popup is visible&lt;BR /&gt;reactiveUtils.watch(() =&amp;gt; view.popup?.visible, (event) =&amp;gt; { if (editor.viewModel.state === "editing-existing-feature") { view.closePopup(); } else { features = view.popup.features; } });&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/////////// MY ATTEMPT -&amp;gt; UNSUCCESSFUL;;&amp;nbsp; DATA STILL UPDATED&lt;/P&gt;&lt;P&gt;parcelLayer.on("apply-edits", (event) =&amp;gt;&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;const validd = validData(editFeature.attributes);&lt;/P&gt;&lt;P&gt;if (validd == false) { return;}&lt;/P&gt;&lt;P&gt;else&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;view.ui.remove(editor);&lt;BR /&gt;// Iterate through the features&lt;BR /&gt;features.forEach((feature) =&amp;gt; {&lt;BR /&gt;// Reset the template for the feature if it was edited&lt;BR /&gt;feature.popupTemplate = editablelPopup;&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;// Open the popup again and reset its content after updates were made on the feature&lt;BR /&gt;&amp;nbsp;if (features) {&amp;nbsp;view.popup.open({&amp;nbsp;features: features&amp;nbsp;});&amp;nbsp;}&lt;/P&gt;&lt;P&gt;//Cancel the workflow so that once edits are applied, a new popup can be displayed&lt;BR /&gt;editor.viewModel.cancelWorkflow();&lt;/P&gt;&lt;P&gt;}//end else&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;});&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2024 13:06:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/validate-editor-widget-edits-before-saving/m-p/1412242#M84377</guid>
      <dc:creator>RichardRhone1</dc:creator>
      <dc:date>2024-04-19T13:06:10Z</dc:date>
    </item>
  </channel>
</rss>

