Select to view content in your preferred language

applyedits successful but throws error

2256
8
03-20-2013 10:05 AM
aubinmaynard
Deactivated User
I've been able to successfully use a form to update a feature service using:
testupdate.applyEdits(null, [params], null,  function test1(){alert("good to go")}, function(error){
  console.log(error);
} );
.
However, the error function always throws  "TypeError: _17b.setAttributes is not a function" in firebug.

anyone have any thoughts where to look for this _17b.setAttributes or what it is?
0 Kudos
8 Replies
DianaBenedict
Frequent Contributor
What does your "params" graphic look like that you are attempting to modify? The name gives me the impression that it is already an array.

Verify that the "params" is a single valid graphic.
Does it have the follwoing properties set correctly?
graphic.geometry
graphic.attributes

Also, what feature type is geometry that you are modifying? Note that the Javascript API does not allow you to modify Polylines that are m-aware.
0 Kudos
aubinmaynard
Deactivated User
what does your [param] graphic look like that you are attempting to modify?
verify that the following properties are set correctly:
graphic.geometry
graphic.attributes

Also, what feature type is geometry that you are modifying? Note that the Javascript API does not allow you to modify Polylines that are m-aware.


No graphics, i've set the feature service to :
function init() {
          //This sample requires a proxy page to handle communications with the ArcGIS Server services. You will need to  
        //replace the url below with the location of a proxy on your machine. See the 'Using the proxy page' help topic 
        //for details on setting up a proxy page.
        esri.config.defaults.io.proxyUrl = "proxy.php";
  testupdate = new esri.layers.FeatureLayer("https:myservice",{
          mode: esri.layers.FeatureLayer.MODE_ONDEMAND, //QUERY_SELECTION is working as well
          outFields: ['*']
               
     }); 
  //build query
        queryTask = new esri.tasks.QueryTask("https:myservice");

        //build query filter
        query = new esri.tasks.Query();
        query.returnGeometry = false;
        query.outFields = ['*'];
  console.log("php id", ProjID);
     dojo.connect(dojo.byId("saveclose"), "onClick", querytable());
   }


So there is no graphic, i then generate the param through script, ending with something like:
attributes
{attributes:{ Project_Name="Ballew Avenue ", Survey_By= "John Smith", Survey_Date="1/24/2012", more...}};

The edits are successful, but the error still occurs. I'm working with a point layer (no m or z values).   Also, firebug is telling me the error happens in FeatureLayer.js (esri file).
0 Kudos
aubinmaynard
Deactivated User
what does your [param] graphic look like that you are attempting to modify?
verify that the following properties are set correctly:
graphic.geometry
graphic.attributes

Also, what feature type is geometry that you are modifying? Note that the Javascript API does not allow you to modify Polylines that are m-aware.


No graphics, i've set the feature service to :
function init() {
          //This sample requires a proxy page to handle communications with the ArcGIS Server services. You will need to  
        //replace the url below with the location of a proxy on your machine. See the 'Using the proxy page' help topic 
        //for details on setting up a proxy page.
        esri.config.defaults.io.proxyUrl = "proxy.php";
  testupdate = new esri.layers.FeatureLayer("https:myservice",{
          mode: esri.layers.FeatureLayer.MODE_ONDEMAND, //QUERY_SELECTION is working as well
          outFields: ['*']
               
     }); 
  //build query
        queryTask = new esri.tasks.QueryTask("https:myservice");

        //build query filter
        query = new esri.tasks.Query();
        query.returnGeometry = false;
        query.outFields = ['*'];
  console.log("php id", ProjID);
     dojo.connect(dojo.byId("saveclose"), "onClick", querytable());
   }


So there is no graphic, i then generate the param through script, ending with something like:
attributes
{attributes:{ Project_Name="Ballew Avenue ", Survey_By= "John Smith", Survey_Date="1/24/2012", more...}};

The edits are successful, but the error still occurs. I'm working with a point layer (no m or z values).   Also, firebug is telling me the error happens in FeatureLayer.js (esri file).
0 Kudos
danbecker
Frequent Contributor
are you certain your featureLayer is editable? may be worth throwing it into a arcgis.com map and attempting to create a feature.
Maybe an error with the sde gdb and not your app.
0 Kudos
DianaBenedict
Frequent Contributor
Assuming that you are using a FeatureService then you should make sure to use the FeatureLayer.queryFeatures methods rather than the query task.
http://help.arcgis.com/en/webapi/javascript/arcgis/jsapi/featurelayer.html#FeatureLayer/queryFeature...

Once you have retrieved your results, verify that the graphic of interest has the properties that you need.

If not then there is some underlying issue with your service or SDE database (as pointed out in above post).

Test your code with the ESRI sample feature service:
http://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/0

where .../0 is the first layer in the feature service that they are interested in.
0 Kudos
aubinmaynard
Deactivated User
I have been using several out of the box samples to successfully edit the geometry and attributes (and in a map) of my Feature Service.  A little more background:

1. I run a query and populate an extensive html form with the attributes.
2. on form submit, my script creates the object from the form elements and
3.dumps it into the applyedits function.
4. all the fields successfuly update, but
5. my error function still spits out the error. 
6. I've recreated my sde.

Thanks for help so far, and I'll try to change the query method, and see if that changes anything.  Its just really really weird that the update is working, but still an error.

Assuming that you are using a FeatureService then you should make sure to use the FeatureLayer.queryFeatures methods rather than the query task.
http://help.arcgis.com/en/webapi/javascript/arcgis/jsapi/featurelayer.html#FeatureLayer/queryFeature...

Once you have retrieved your results, verify that the graphic of interest has the properties that you need.

If not then there is some underlying issue with your service or SDE database (as pointed out in above post).

Test your code with the ESRI sample feature service:
http://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/0

where .../0 is the first layer in the feature service that they are interested in.
0 Kudos
UrsRichard
Emerging Contributor
I'm running into the same issue. I can correctly apply my edits, but receive the error callback. The features are saved absolutely fine in the geodatabase. I got error TypeError: _271 is undefined.
0 Kudos
aubinmaynard
Deactivated User
The issue for me was that my script was sending requests for editing fields that didn't exist, it would update the existing fields and throw an error.  It turned out the script that pulled the variables from my form was also pulling non-variable related fields and putting it into the request.  If i remember correctly, the issue was specifically related to some code i used to limit the amount of text a user could put in a text area.  I suggest using console.log to look at your request and verify all the fields exist in your database. 

I'm running into the same issue. I can correctly apply my edits, but receive the error callback. The features are saved absolutely fine in the geodatabase. I got error TypeError: _271 is undefined.
0 Kudos