<?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 Control or reset arrays of graphics before applyEdits in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/control-or-reset-arrays-of-graphics-before/m-p/550722#M51307</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;API JS 3.0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ArcGIS 10.1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Oracle 11g&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have to intercept objects to add, update or delete &lt;/SPAN&gt;&lt;SPAN style="text-decoration:underline;"&gt;before &lt;/SPAN&gt;&lt;SPAN&gt;they are sent to server. Because I have to authorize each edit or complete the attributes before they are applied to database.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The featureLayer get an event called &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jsapi/featurelayer.htm#onBeforeApplyEdits"&gt;onBeforeApplyEdits&lt;/A&gt;&lt;SPAN&gt; fired just before the &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jsapi/featurelayer.htm#applyEdits"&gt;applyEdits&lt;/A&gt;&lt;SPAN&gt; function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This event gives 3 arrays of Graphic : adds, updates and deletes. The attributes of adds and updates can be modified but it seems there is no way to reset one of the 3 arrays in the call of applyEdits (REST request send to the server).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anybody knows a way to stop this call? Or maybe to set a check method? I cannot believe there is no way to cancel a delete before it is sent to the server.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note : I cannot just put an event to my delete button. There is too many action wich calls applyEdits&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks by advance&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 13 Aug 2012 09:27:15 GMT</pubDate>
    <dc:creator>PatrickChapuis</dc:creator>
    <dc:date>2012-08-13T09:27:15Z</dc:date>
    <item>
      <title>Control or reset arrays of graphics before applyEdits</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/control-or-reset-arrays-of-graphics-before/m-p/550722#M51307</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;API JS 3.0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ArcGIS 10.1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Oracle 11g&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have to intercept objects to add, update or delete &lt;/SPAN&gt;&lt;SPAN style="text-decoration:underline;"&gt;before &lt;/SPAN&gt;&lt;SPAN&gt;they are sent to server. Because I have to authorize each edit or complete the attributes before they are applied to database.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The featureLayer get an event called &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jsapi/featurelayer.htm#onBeforeApplyEdits"&gt;onBeforeApplyEdits&lt;/A&gt;&lt;SPAN&gt; fired just before the &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jsapi/featurelayer.htm#applyEdits"&gt;applyEdits&lt;/A&gt;&lt;SPAN&gt; function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This event gives 3 arrays of Graphic : adds, updates and deletes. The attributes of adds and updates can be modified but it seems there is no way to reset one of the 3 arrays in the call of applyEdits (REST request send to the server).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anybody knows a way to stop this call? Or maybe to set a check method? I cannot believe there is no way to cancel a delete before it is sent to the server.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note : I cannot just put an event to my delete button. There is too many action wich calls applyEdits&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks by advance&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Aug 2012 09:27:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/control-or-reset-arrays-of-graphics-before/m-p/550722#M51307</guid>
      <dc:creator>PatrickChapuis</dc:creator>
      <dc:date>2012-08-13T09:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: Control or reset arrays of graphics before applyEdits</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/control-or-reset-arrays-of-graphics-before/m-p/550723#M51308</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ok, I have a solution: throw an error. It's really bad but it works.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;dojo.connect(layer, "onBeforeApplyEdits", prepareApplyEdits);
function prepareApplyEdits(adds,updates,deletes) {
 var ok = true;
 if(adds==undefined &amp;amp;&amp;amp; updates==undefined &amp;amp;&amp;amp; deletes!=undefined){
&amp;nbsp; if(&lt;STRONG&gt;confirm&lt;/STRONG&gt;("Do you really want to delete those elements?")){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /** treatement for attributes **/
&amp;nbsp; }else{
&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;ok=false;&lt;/STRONG&gt;
&amp;nbsp; }
 }
 if(&lt;STRONG&gt;!ok&lt;/STRONG&gt;){
&amp;nbsp; layer.clearSelection();
&amp;nbsp; &lt;STRONG&gt;throw new Error();&lt;/STRONG&gt;
 }
}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm really ashamed but it's the only way I found. If anybody has a better idea, he can throw me the rock (or another solution)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:49:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/control-or-reset-arrays-of-graphics-before/m-p/550723#M51308</guid>
      <dc:creator>PatrickChapuis</dc:creator>
      <dc:date>2021-12-11T23:49:21Z</dc:date>
    </item>
  </channel>
</rss>

