Can an arcade attribute rule update a date field?

2358
4
Jump to solution
03-01-2018 11:11 AM
MatthewBaber
Esri Contributor

I am using the date functions in arcade to calculate a date from data stored within a barcode. All works well in sandbox, but applying the attribute rule to a date field causes the error:

ERROR 000358: Invalid expression

Failed to execute (AddAttributeRule).

The return of the expression is a date variable. The rule applies successfully to a text field and triggers and functions as expected. The expression itself validates successfully within the add attribute rule tool. The error only appears after attempting to run the tool against a date field.

Here is a simplified expression:

  1. var inputdate = date(2000,01,01)
  2. return inputdate

Attempting to apply this as an attribute rule to a date field will render the error mentioned above. Any ideas on how I could apply a like expression to a date field?

0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

This might be a separate bug. I was able to add:

var inputdate = date(2000,01,01)
return inputdate

To run the Calculate Field on a date field and the results were correct. 

Thus, I logged a new bug:

BUG-000112098 - ERROR 000358: Invalid expression when applying an Arcade date function to a date field thru Attribute Rules

View solution in original post

4 Replies
XanderBakker
Esri Esteemed Contributor

Could this be related to "BUG-000112055 - The Arcade expression to format date in attribute rules doesn't return the correct year results"? Although in this case it's not about formatting the date, but about storing the date providing a date object with Arcade.

CC Kory Kramer , Supriya_Khadke-esristaff 

0 Kudos
by Anonymous User
Not applicable

I don't think it is related to the bug above since that has to do with formatting and this is a clear error when applying a date object to a date field. I wonder if the date object has to be formatted to match the date fields format in the geodatabase?

yyyy-mm-dd hh:mm:ss AM or PM

Date fields—ArcGIS Pro | ArcGIS Desktop 

I tried the above workflows mentioned by Matthew and experienced the same error when applying a date to a date field but no error when applying it to a text field. I will look into it some more and post any updates I find. 

XanderBakker
Esri Esteemed Contributor

Hi Supriya_Khadke-esristaff , thanks for jumping in and investigate on what might be the problem.

I don't think the date should be formatted (as string) when it will be stored as a date. Sending a date as date object should work, since this avoids any misinterpretation due to differences in regional settings. 

by Anonymous User
Not applicable

This might be a separate bug. I was able to add:

var inputdate = date(2000,01,01)
return inputdate

To run the Calculate Field on a date field and the results were correct. 

Thus, I logged a new bug:

BUG-000112098 - ERROR 000358: Invalid expression when applying an Arcade date function to a date field thru Attribute Rules