<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Saving attribute to editable layer problem in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/saving-attribute-to-editable-layer-problem/m-p/573463#M53587</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello again,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I need to save a shape with attributes, unfortunately the field name in my code exists as a variable, and I can't get the setAttributes method to work with a variable for the field name, only by hard-coding the field name.&amp;nbsp; What I'm doing is applying the attribute to the graphic before saving, the below code works great every time:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;var theValue = "Bob"
graphic.setAttributes({ "FirstName": theValue });&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;However the following code will not work, my shape gets saved but without the desired attribute:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;var theField = "FirstName"
var theValue = "Bob"
graphic.setAttributes({ theField : theValue });&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;Can anyone please suggest how I can solve this issue?&amp;nbsp; Basically this comes from the fact the user is using a custom tool to save shapes to any editable layer, so the field names cannot be hard-coded, I have to get them from the layer they are trying to save to as variables.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mark.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 30 Aug 2011 14:55:54 GMT</pubDate>
    <dc:creator>MarkSmith</dc:creator>
    <dc:date>2011-08-30T14:55:54Z</dc:date>
    <item>
      <title>Saving attribute to editable layer problem</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/saving-attribute-to-editable-layer-problem/m-p/573463#M53587</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello again,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I need to save a shape with attributes, unfortunately the field name in my code exists as a variable, and I can't get the setAttributes method to work with a variable for the field name, only by hard-coding the field name.&amp;nbsp; What I'm doing is applying the attribute to the graphic before saving, the below code works great every time:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;var theValue = "Bob"
graphic.setAttributes({ "FirstName": theValue });&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;However the following code will not work, my shape gets saved but without the desired attribute:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;var theField = "FirstName"
var theValue = "Bob"
graphic.setAttributes({ theField : theValue });&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;Can anyone please suggest how I can solve this issue?&amp;nbsp; Basically this comes from the fact the user is using a custom tool to save shapes to any editable layer, so the field names cannot be hard-coded, I have to get them from the layer they are trying to save to as variables.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mark.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Aug 2011 14:55:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/saving-attribute-to-editable-layer-problem/m-p/573463#M53587</guid>
      <dc:creator>MarkSmith</dc:creator>
      <dc:date>2011-08-30T14:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: Saving attribute to editable layer problem</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/saving-attribute-to-editable-layer-problem/m-p/573464#M53588</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;graphic.setAttributes takes a JS object as it's argument so you can do this by using a different syntax to create your object:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
// create a new object
var attrs = {};
// create a property with the field to be updated
// and set the new property's value
attrs[theField] = theValue;
// or...
attrs['FirstName'] = 'Bob';
graphic.setAttributes(attrs);
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:41:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/saving-attribute-to-editable-layer-problem/m-p/573464#M53588</guid>
      <dc:creator>derekswingley1</dc:creator>
      <dc:date>2021-12-12T00:41:07Z</dc:date>
    </item>
    <item>
      <title>Re: Saving attribute to editable layer problem</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/saving-attribute-to-editable-layer-problem/m-p/573465#M53589</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you very much for your speedy reply, and yes this works fine.&amp;nbsp; Sometimes I really wish I knew what I was doing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a lot!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mark.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Aug 2011 06:55:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/saving-attribute-to-editable-layer-problem/m-p/573465#M53589</guid>
      <dc:creator>MarkSmith</dc:creator>
      <dc:date>2011-08-31T06:55:21Z</dc:date>
    </item>
    <item>
      <title>Re: Saving attribute to editable layer problem</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/saving-attribute-to-editable-layer-problem/m-p/573466#M53590</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Glad to help!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Aug 2011 13:30:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/saving-attribute-to-editable-layer-problem/m-p/573466#M53590</guid>
      <dc:creator>derekswingley1</dc:creator>
      <dc:date>2011-08-31T13:30:21Z</dc:date>
    </item>
  </channel>
</rss>

