Is there a simple call from arcgis javascript api 4.x to delete all records from a feature class
Jay,
This is the only way I know how.
Perfect
Is there a way to get an alert when the applyEdits is completed or successful? Want to verify its done and then write to the same FC.
Sure, applyEdits returns a promise.
featureLayer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">queryFeatures</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">then</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">function</SPAN><SPAN class="punctuation token">(</SPAN>results<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">{</SPAN> featureLayer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">applyEdits</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN>deleteFeatures<SPAN class="punctuation token">:</SPAN> results<SPAN class="punctuation token">.</SPAN>features<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">then</SPAN><SPAN class="punctuation token">(</SPAN>results<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">{</SPAN> <SPAN class="comment token">//do something here</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
hmmmm..
I added a ; at the end of appyEdits but no go...
featureLayer.queryFeatures().then(function(results){ featureLayer.applyEdits({deleteFeatures: results.features}).then(results){ //do something here }; });<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.