delete all records from FC

178
7
Jump to solution
03-27-2020 02:15 PM
jaykapalczynski
Frequent Contributor

Is there a simple call from arcgis javascript api 4.x to delete all records from a feature class

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

Jay,

   This is the only way I know how.

featureLayer.queryFeatures().then(function(results){
  featureLayer.applyEdits({deleteFeatures: results.features});
});

View solution in original post

7 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Jay,

   This is the only way I know how.

featureLayer.queryFeatures().then(function(results){
  featureLayer.applyEdits({deleteFeatures: results.features});
});
jaykapalczynski
Frequent Contributor

Perfect

0 Kudos
jaykapalczynski
Frequent Contributor

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.

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Jay,

  Sure, applyEdits returns a promise.

featureLayer.queryFeatures().then(function(results){
  featureLayer.applyEdits({deleteFeatures: results.features}).then(results){
    //do something here
  }
});
0 Kudos
jaykapalczynski
Frequent Contributor

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
  };
});‍‍‍‍‍

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Jay, sorry for the bad code I forgot the function part.

featureLayer.queryFeatures().then(function(results){
  featureLayer.applyEdits({deleteFeatures: results.features}).then(function(results2){
    //do something here
  });
});‍‍‍‍‍
0 Kudos
jaykapalczynski
Frequent Contributor

think I got it with this

featureLayer.queryFeatures().then(function (results) {
  featureLayer.applyEdits({ deleteFeatures: results.features }).then(function (results) {
         alert("Im done and now building the multipart features");
  });
});
0 Kudos