I can't write to a feature service using applyEdits()

288
7
03-21-2019 06:02 PM
deleted-user-hyxJSx81t8OL
New Contributor

Hi. I'm fairly new to the javascript api. Would appreciate any help. I'm trying to write a feature to a feature service using the featureLayer.applyEdits() function. This is part of custom buffer widget I'm trying to build. The command is part of a feature action. Basically, you select a point and click on the feature action, "add buffer", and a buffer is created.

It seems the applyEdits command is being executed completely. There seems to be no errors. But when I check the feature service, no feature has been added. I've attached screenshots below.

Thanks.

Tags (1)
0 Kudos
7 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Johnel,

   How are you checking if the edits are applied? Have you tried logging the editResult object in the response function? Does you layer has any required attribute fields?

0 Kudos
deleted-user-hyxJSx81t8OL
New Contributor

Hi, I'm simply checking the feature service in a webmap. No required attribute fields.

0 Kudos
JohnGrayson
Esri Regular Contributor

What version of the JS API are a you using?  You're creating the FeatureLayer using 3.x syntax but you're calling applyEdits() in a 4.x manner.

0 Kudos
deleted-user-hyxJSx81t8OL
New Contributor

Hi John, I think it's using 3.x. I simply downloaded the Web AppBuilder for ArcGIS SDK (2.11) and started following tutorials online. I'm thinking it's good to use 4.x but I'm not sure how to use 4.x. I know it's probably just a matter of changing the version of the script imported in one of the html docs but I can't find it. Or is there a different download?

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Johnel,

   Your issue is as John has pointed out you are mixing code from 4.x and 3.x. WAB 2.11 is built using 3.x so you should Not be using any 4.x code or attempting to change the API urls. The way you define your layer in your first code block is fine that is the 3.x way. The issue is the second code block where you create you point. That code is written based on 4.x and thus you issue.

var point = new Point([151.106,-33.932]);
var pointGraphic = new Graphic(point);
layer.applyEdits([pointGraphic], null, null, lang.hitch(this,
  function (editResults) {
    console.log(editResults);
  }),
  function (error) {
    console.log("==================================");
    console.error("[ applyEdits ] FAILURE: ", error.code, error.name, error.message);
    console.log("error = ", error);
  });
deleted-user-hyxJSx81t8OL
New Contributor

Hi,

I've changed the syntax, am now using 3.x syntax. But I still can't write. See code I'm using below.

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Johnel,

   Using my exact code provided did you get to the error console.log or the success console.log?

0 Kudos