adding new record using feature layer

3486
8
04-07-2016 05:23 AM
NadirHussain
Occasional Contributor II

Dear All the below code is adding new record in my feature layer

var officeFeatureLayer=new esri.layers.FeatureLayer("http://myserver/arcgis/rest/services/myservice/FeatureServer/0");

      var mp=esri.geometry.webMercatorToGeographic(evt.mapPoint);

      var pt = new esri.geometry.Point(evt.mapPoint.x, evt.mapPoint.y, new esri.SpatialReference({ wkid: 4326 }));

       var myGeom  = esri.geometry.geographicToWebMercator(pt);

        pt=myGeom;

        var attr = {"x_coordinate":evt.mapPoint.x,"y_coordinate":evt.mapPoint.y,"office_id":"1000",office_nam:" new office"};

         var addGraphic = new esri.Graphic(pt,null,attr,null);

           officeFeatureLayer.applyEdits([addGraphic], null, null, function (adds, updates, deletes) {

                              dynamiclayer.refresh();

                                 alert("Added feature successfully<br />OBJECTID: " + adds[0].objectId );

               });

when i execute the code my alert give me message successfully and objectID give me the exact id of total number of records in feature class plus one.but i could not find the record where it is going in geodatabase.Any idea in whice table it is stored.i am not using any attribute inspector.i have my own custom form from whict i am getting my values.please help.

thanks in advance.

0 Kudos
8 Replies
RobertScheitlin__GISP
MVP Emeritus

Nadir,

  Why are you going from webmercator to geographic and right back to webmercator?..

var mp=esri.geometry.webMercatorToGeographic(evt.mapPoint);

      var pt = new esri.geometry.Point(evt.mapPoint.x, evt.mapPoint.y, new esri.SpatialReference({ wkid: 4326 }));

       var myGeom  = esri.geometry.geographicToWebMercator(pt)

0 Kudos
NadirHussain
Occasional Contributor II

Dear Robert,

Always you help me.For this thanks  in advance.

mp=esri.geometry.webMercatorToGeographic(evt.mapPoint);

the above statment i am using to get my point in geographic coordinates.my base map is bing map.thats why i want to get my point in geogaphic and want to store in geodatabase.the next below statment

var myGeom  = esri.geometry.geographicToWebMercator(pt)

to display my point inside my extant.otherwise my point goes outside my extent.these are the reason i am using these two statments.the next thing i have nearly 15 attributes in my feature layer and in all null is allowed.

var attr = {"x_coordinate":evt.mapPoint.x,"y_coordinate":evt.mapPoint.y,"office_id":"1000",office_nam:" new office"};

         var addGraphic = new esri.Graphic(pt,null,attr,null);

           officeFeatureLayer.applyEdits([addGraphic], null, null, function (adds, updates, deletes) {

                              dynamiclayer.refresh();

                                 alert("Added feature successfully<br />OBJECTID: " + adds[0].objectId );

               });

in my attr object i am using only 5 attributes.that can be the reason that my alert show adding record successfully,but record actully not going to geodatabase feature class.please help.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Nadir,

  You should supply all 15 attributes and set the others to null.

0 Kudos
NadirHussain
Occasional Contributor II

Dear Robert

i am still confused.

i am adding point on the map.when i click the point.one point add on the map by using current symbology of point layer.in my alert it give me the id of new added point that is the next object id of point in feature layer.this point is permanent there.see even i refresh and rebuild the application this point always come.even i restart my computer but this point permanentally there.problem is that in which table of feature layer this point store. how to find this point in geodatabase table.please help.this attached image showing my problem.

please see attached image.

the point inside black circle.i add it from my tool.even reload or refresh or rebuild my application.this point is always there like the points coming from geodatabase.so where this point store in which table of geodatabase.

help.

0 Kudos
NadirHussain
Occasional Contributor II

Dear Robert

i am still confused.

i am adding point on the map.when i click the point.one point add on the map by using current symbology of point layer.in my alert it give me the id of new added point that is the next object id of point in feature layer.this point is permanent there.see even i refresh and rebuild the application this point always come.even i restart my computer but this point permanentally there.problem is that in which table of feature layer this point store. how to find this point in geodatabase table.please help.this attached image showing my problem.

please see attached image.

the point inside black circle.i add it from my tool.even reload or refresh or rebuild my application.this point is always there like the points coming from geodatabase.so where this point store in which table of geodatabase.

help.

my code is below

var PtFeatureLayer = new FeatureLayer("http://localhost:6080/arcgis/rest/services/myService/FeatureServer/0");

                    esriConfig.defaults.io.alwaysUseProxy = false;

                   

                    var attr = {

                        office_id:  1000,

                        office_nam: "HELLO",

                        no_of_peop:100,

                        x_coordina:2.5,

                        y_coordina:3.45,

                        city_id:2.2,

                        cate_id:2,

                        gender_id:2,

                     

     

                    };

                    var graphic = new esri.Graphic(clickedPoint, null, attr, null);

                    PtFeatureLayer.applyEdits([graphic], null, null, function (adds, updates, deletes) {

                        var query = new esri.tasks.Query();

                        query.objectIds = [adds[0].objectId];

                        //featureLayerEdit.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW);

                        dynamicMapServiceLayer.refresh();

                        alert("Added feature successfully, OBJECTID: " + adds[0].objectId);

                    }, function (err) {

                        //when an error occurs

                        alert("Apply Edits Failed: " + err.message);

                    });

1111.png

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Nadir,

  The point is added to whatever feature this FeatureServer service is pointing to:

http://localhost:6080/arcgis/rest/services/myService/FeatureServer/0

0 Kudos
NadirHussain
Occasional Contributor II

Dear robert ,

my insertion module was working fine.but from yesterday it is throwing this error.i could not find what the problem is.i just remove one domain from my one field.and it start throwing error.

"apply edits failed:ESRI.config.defaults.io.proxyURL is not set.if making a request CORS enabled.Please push the domian into ESRI.config.defaults.io.CORSENABLED servers.

please help.

Thanks in advance.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Nadir,

  Did you get this worked out? Sorry the error seems pretty self explanatory. You need to add the apps domain to the CORS enabled server list or add it to the serverUrls in your proxy.

0 Kudos