Date.now() for esriFieldTypeDate?

1269
4
Jump to solution
02-17-2017 01:39 PM
NaciDilekli
Occasional Contributor

Based on Robert Scheitlin, GISP‌'s answer, I have been trying to set a date attribute programmatically using the following expression:

evt.adds[0].attributes.eventdate = new Date(Date.now());    ‍

This generates the following error: "Error: Unable to complete operation"

However, if I try to set the value of a text field it works fine, e.g.:

evt.adds[0].attributes.description = "test";

So I suppose the problem has to do with the field type. How can this be resolved?

Here is my entire code for reference. Thanks

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Naci,

Try:

evt.adds[0].attributes.eventdate = new Date(Date.now()).getTime();

View solution in original post

4 Replies
RobertScheitlin__GISP
MVP Emeritus

Naci,

  What is the field type for your eventdate field?

0 Kudos
NaciDilekli
Occasional Contributor

Robert,

It is esriFieldTypeDate. Here is the full information of the field: "eventdate ( type: esriFieldTypeDate , alias: Date , editable: true , nullable: true , length: 8 )"

This is the service I am using: Layer: Wildfire Response Points (ID: 0) 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Naci,

Try:

evt.adds[0].attributes.eventdate = new Date(Date.now()).getTime();
NaciDilekli
Occasional Contributor

Awesome, thanks!

0 Kudos