<?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 Re: Update a field in Web AppBuilder Custom Widgets Questions</title>
    <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/update-a-field/m-p/792254#M4271</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Robert,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately it didn't help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you ment to define two different variables, isn't it? something like:&lt;/P&gt;&lt;P&gt;&lt;SPAN class="keyword"&gt;var currentDate = &lt;SPAN class="keyword"&gt;new&lt;/SPAN&gt; Date();&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="keyword"&gt;var &lt;STRONG&gt;currentDate1 &lt;/STRONG&gt;= Date.UTC(currentDate.getUTCFullYear(), currentDate.getUTCMonth(), currentDate.getUTCDate(), currentDate.getUTCHours(), currentDate.getUTCMinutes(), currentDate.getUTCSeconds(), &lt;SPAN class="number"&gt;0&lt;/SPAN&gt;);&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;attInspector.on(&lt;SPAN class="string"&gt;"attribute-change", &lt;SPAN class="keyword"&gt;function&lt;/SPAN&gt;(evt) {&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; feature = evt.feature;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; feature.attributes[&lt;SPAN class="string"&gt;"date1"] = &lt;STRONG&gt;currentDate1&lt;/STRONG&gt;;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; feature.getLayer().applyEdits(&lt;SPAN class="keyword"&gt;null, [feature], &lt;SPAN class="keyword"&gt;null&lt;/SPAN&gt;);&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;});&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But anyway, both of them don't work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think it's more timimg Issue rather than the Date format. Only once, during Debug, I saw the date entered but I cannot reproduce it any more.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it's also related to the Editor or AttributeInspector classes in Javascript API rather than the Web AppBuilder.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot,&lt;/P&gt;&lt;P&gt;Miri&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 08 Feb 2015 16:11:55 GMT</pubDate>
    <dc:creator>MiriEshel</dc:creator>
    <dc:date>2015-02-08T16:11:55Z</dc:date>
    <item>
      <title>Update a field</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/update-a-field/m-p/792252#M4269</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to automatically update a date field with Date.now() value using the Edit widget with some changes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What ever I do, it does not update the field. &lt;/P&gt;&lt;P&gt;Can someone tell me what's wrong with my code?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this.editor = new Editor(params, this.editDiv);&lt;BR /&gt;this.editor.startup();&lt;BR /&gt;var feature;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;var attInspector = this.editor.attributeInspector;&amp;nbsp; &lt;BR /&gt;attInspector.showObjectID = false;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;var theMap = this.editor.settings.map;&lt;BR /&gt; var saveButton = new dijit.form.Button({label:"שלח","class":"saveButton"});&amp;nbsp; &lt;BR /&gt; dojo.place(saveButton.domNode, attInspector.deleteBtn.domNode, "before");&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; saveButton.on("click", function(evt) {&lt;BR /&gt;&amp;nbsp; if (feature == null) &lt;BR /&gt;&amp;nbsp;&amp;nbsp; alert("Pleae enter values");&lt;BR /&gt;&amp;nbsp; else {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if (feature.attributes["description"] == null) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; alert("Description field is required");&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; &lt;STRONG&gt; feature.attributes["date1"] = Date.now();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; theMap.infoWindow.hide();&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt; });&lt;BR /&gt; &lt;BR /&gt; attInspector.on("attribute-change", function(evt) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; feature = evt.feature;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;feature.attributes["date1"] = Date.now();&lt;/STRONG&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; feature.getLayer().applyEdits(null, [feature], null);&lt;BR /&gt; });&lt;/P&gt;&lt;P&gt; theMap.infoWindow.resize(350, 600);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.resize();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; },&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot,&lt;/P&gt;&lt;P&gt;Miri &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2015 14:42:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/update-a-field/m-p/792252#M4269</guid>
      <dc:creator>MiriEshel</dc:creator>
      <dc:date>2015-02-05T14:42:27Z</dc:date>
    </item>
    <item>
      <title>Re: Update a field</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/update-a-field/m-p/792253#M4270</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Miri,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var currentDate = new Date();
var currentDate = Date.UTC(currentDate.getUTCFullYear(), currentDate.getUTCMonth(), currentDate.getUTCDate(), currentDate.getUTCHours(), currentDate.getUTCMinutes(), currentDate.getUTCSeconds(), 0);

attInspector.on("attribute-change", function(evt) {
&amp;nbsp;&amp;nbsp; feature = evt.feature;
&amp;nbsp;&amp;nbsp; feature.attributes["date1"] = currentDate;
&amp;nbsp;&amp;nbsp; feature.getLayer().applyEdits(null, [feature], null);
});&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reference thread: &lt;A href="https://community.esri.com/message/265160" target="_blank"&gt;Re: Hard-code Attribute Values for Fields with AttributeInspector?&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:06:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/update-a-field/m-p/792253#M4270</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-12-12T09:06:16Z</dc:date>
    </item>
    <item>
      <title>Re: Update a field</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/update-a-field/m-p/792254#M4271</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Robert,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately it didn't help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you ment to define two different variables, isn't it? something like:&lt;/P&gt;&lt;P&gt;&lt;SPAN class="keyword"&gt;var currentDate = &lt;SPAN class="keyword"&gt;new&lt;/SPAN&gt; Date();&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="keyword"&gt;var &lt;STRONG&gt;currentDate1 &lt;/STRONG&gt;= Date.UTC(currentDate.getUTCFullYear(), currentDate.getUTCMonth(), currentDate.getUTCDate(), currentDate.getUTCHours(), currentDate.getUTCMinutes(), currentDate.getUTCSeconds(), &lt;SPAN class="number"&gt;0&lt;/SPAN&gt;);&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;attInspector.on(&lt;SPAN class="string"&gt;"attribute-change", &lt;SPAN class="keyword"&gt;function&lt;/SPAN&gt;(evt) {&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; feature = evt.feature;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; feature.attributes[&lt;SPAN class="string"&gt;"date1"] = &lt;STRONG&gt;currentDate1&lt;/STRONG&gt;;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; feature.getLayer().applyEdits(&lt;SPAN class="keyword"&gt;null, [feature], &lt;SPAN class="keyword"&gt;null&lt;/SPAN&gt;);&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;});&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But anyway, both of them don't work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think it's more timimg Issue rather than the Date format. Only once, during Debug, I saw the date entered but I cannot reproduce it any more.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it's also related to the Editor or AttributeInspector classes in Javascript API rather than the Web AppBuilder.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot,&lt;/P&gt;&lt;P&gt;Miri&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 08 Feb 2015 16:11:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/update-a-field/m-p/792254#M4271</guid>
      <dc:creator>MiriEshel</dc:creator>
      <dc:date>2015-02-08T16:11:55Z</dc:date>
    </item>
  </channel>
</rss>

