Select to view content in your preferred language

Delete record from custom web application

3840
7
Jump to solution
12-21-2015 09:57 AM
RaymondGoins
Regular Contributor

Can I delete a record through a web application without using the ESRI jsapi?

Here is what I have

I have a point feature class. I am adding features through the GeoForm application.

I have created a web application using php, JS and html which reads directly from the table(Oracle) to retrieve the attributes. The web app allows the rows to be edited. This all seems to be working fine. I want to have a button which allows the user to delete a record. Can I do this through a regular oracle query based off the OBJECTID or do I need to use the JSAPI and delete is through the service which I have published. The layer is not versioned.

Thanks

Ray

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Ray,

   Your layer that you want to delete the feature from will need to be published as a feature access enabled Feature Service in ArcGIS Server. Once you have that then there is a rest endpoint for deleting feature(s) based on ObjectId(s). And it will be a simple esri/request | API Reference | ArcGIS API for JavaScript to complete the delete.

View solution in original post

7 Replies
RobertScheitlin__GISP
MVP Emeritus

Ray,

   You should use the jsapi to delete the record. Just deleting the row in the table does not handle all the other SQL operations that occur when a feature is deleted using esri software.

0 Kudos
RaymondGoins
Regular Contributor

OK that was my concern.

Do you know of any sample code I can look at? I was looking around briefly and had a hard time finding some code to do what I want which is just call the JSAPI and be able to delete the row by just having the objectid. There will be no map or anything just a basic list of rows with a delete link. I want to call the api once the delete button has been pressed.

Thanks again

Ray

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Ray,

   Your layer that you want to delete the feature from will need to be published as a feature access enabled Feature Service in ArcGIS Server. Once you have that then there is a rest endpoint for deleting feature(s) based on ObjectId(s). And it will be a simple esri/request | API Reference | ArcGIS API for JavaScript to complete the delete.

RaymondGoins
Regular Contributor

Thanks. You got me in the right direction.

Running into another issue. I make the request but not getting back the response I'm looking for.

Here is my javascript code. I am using jQuery as well

$(".deltrench").each(function(){
  $(this).click(function(){
    //var objid = $(this).data("objid");
    var objid = 17000;
    var delurl = 'http://gismapserver:6080/arcgis/rest/services/Holes/MapServer/0/deleteFeatures';
    $.ajax({
      type: "POST",
      url: delurl,
      data: {
        "objectIds": objid,
        "f": "json"
      },
      success: function(data) {
        data = jQuery.parseJSON(data);
        console.log(data);
      }
    });

  });
});

I post this to the server and there is a huge response. One thing I notice is

canModifyLayer:false

Is there something I need to do extra? Seems like it may be a permissions thing. Do I need to pass along a username and password to use the service? When I published the service I did make it public. We are on an Intranet with no external access to the server.

Thanks for your help again

Ray

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Ray,

   When you setup the feature access for the map service did you make sure that the capabilities on Feature Access, included Operations allowed: Create, Delete, Update?

0 Kudos
RaymondGoins
Regular Contributor

holesFS.jpgYes.

I did notice in my script the url was incorrect. I have since changed it to

http://gismapserver:6080/arcgis/rest/services/Holes/FeatureServer/0/deleteFeatures

Now I get an empty object back as a response.

Ray

0 Kudos
RaymondGoins
Regular Contributor

It actually worked fine once I passed a valid objectid to the script. Reading the post here

Delete Features (Operation)

I thought I would get back a response saying it failed.

Once a valid ObjectID was passed the feature was deleted.

Thanks for your help Robert. I will mark this question as answered.

Happy holidays to you.

Ray

0 Kudos