Populate Date field with Arcade

4319
11
05-06-2019 07:42 AM
ScottEvans6
New Contributor III

I am trying to populate a date field, with the date and time from the exact moment another field is updated. I am using Arcade to do this. I have been able to get the local time from the machine, and populate the date field when the other field is updated, but it keeps updating every second. I want the time field to stay at the time when the other field is first updated, and to not keep automatically updating. Below is the Arcade code:

var ResDate = ToLocal(TimeStamp())
var Status = $feature.Status

IIf(Status == 'Resolved', ResDate, null)

I am then putting this arcade expression in the layer's pop up. So, once a feature's status field is changed from 'Unresolved' to 'Resolved', I want the time to be grabbed and put in the new resolve date field. However, that time keeps getting pulled and updated. I tried using the 'break' operator for arcade with no success. So essentially, I am hoping to pull the time once, and leave it. Any help would be awesome! Arcade is still new and finding detailed documentation can be difficult. Thanks!

Scott

0 Kudos
11 Replies
KellyGerrow
Esri Frequent Contributor

Hi Scott,

Are you trying to display the field using Arcade in calculate function or are you calculating the expression in a pop up? When a field is calculated using Arcade a one time calculation is made. If you are running this calculation and include the time stamp, it will take the timestamp at the time that you run the tool.

When calculating an expression in a pop-up using arcade (which I think is what you are doing), the arcade expression runs and calculates when the map is loaded and the pop-up is called. The timestamp will then be displayed based on when the map was opened. 

I don't think either of these functions will address your need.

I think using editor tracking (keep track of who created and updated features) and an arcade expression to calculate resolved based on the date created or updated field. Can you provide some more details about the workflow? How does the time get updated?

-Kelly

ScottEvans6
New Contributor III

Hey Kelly,

The issue is that the editor tracking [EditDate] field gets updated every time a feature is touched. Let's say that the user marks the point feature as resolved, and the [EditDate] field get updated with the date and time they marked the feature resolved. Then they go back in a week later to add attachments, or extra notes and follow up information. That [EditDate] now gets updated as well. In reality, I want the exact date and time that the user marked the issue resolved initially. Does that help?

Thanks,

Scott

0 Kudos
XanderBakker
Esri Esteemed Contributor

I think this might become possible in the future when support for attribute rules is implemented in ArcGIS Online and the Field Apps (at this moment there is only support for attribute rules when you have Enterprise): https://pro.arcgis.com/en/pro-app/help/data/geodatabases/overview/an-overview-of-attribute-rules.htm

This would require the a Calculation Attribute Rule: https://pro.arcgis.com/en/pro-app/help/data/geodatabases/overview/calculation-attribute-rules.htm#GU...

0 Kudos
ScottEvans6
New Contributor III

Xander,

This makes sense to be a part of ArcGIS Online. Is this functionality planned for a future AGOL update soon?

Scott

0 Kudos
KellyGerrow
Esri Frequent Contributor

Hi Scott,

This is feedback that we hear from time to time, but don't have a planned release for this currently. Have you found a solution to this or is this still a need that you have? If it is still something that you need, I'd like to set up a time to chat about this in more detail.

Thanks,

-Kelly

ScottEvans6
New Contributor III

Sure, a chat with you would be great! We would love this functionality at our organization. Let me know when you are available next. Thanks!

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi Scott Evans and Kelly Gerrow ,

I went back and read the original question again and think that Workforce will enable you access to the exact date and time an issue was solved. Every change in status comes with it date time field to track those changes. 

Kelly Gerrow , what I have seen across GeoNet is the request to be able to create dynamic symbology with more complex Arcade expressions that involve retrieving data from attachments, related tables and other layers. Since this would have a high impact on rendering, it would be very helpful if we would have the option to schedule field calculations or have support for attribute rules in ArcGIS Online so that dynamic data could be rendered correctly.

To share a use case; suppose you do inspections on assets in the field and those inspection results are stored in a related table of the asset layer so you have access to the history and you want to symbolize the inspection results from the related table. This is only possible when you do a field calculation and bring the results back in the asset layer. However, since fieldwork continues and the data is dynamic, you will have to repeat the calculation frequently. Perhaps on the short term scheduled geoprocessing that will be released in ArcGIS Pro 2.5 next month could be a temporal solution. However, support for attribute rules or scheduled calculations in AGOL would make this workflow more elegant. 

I will have a look at some recent questions where I contributed to include some links to user questions to provide some more use cases.  

Happy New Year!

0 Kudos
MarquesMunson1
Occasional Contributor

Hi Kelly,

I would be highly interested in this if it is possible. To take editor tracking and somehow an arcade expression to populate a field when another field is updated. Can you assist with this?

The workflow is: a feature class of countries and a user can update a particular attribute of that country. Would like it so that the date field is populated when that one attribute is updated/changed.