How to not update a field with calculated expression

497
2
02-06-2023 07:23 PM
Labels (2)
RobCahalan1
New Contributor III

I have a Survey Date attribute in feature layer that I have set to populate with calculated expression in the smart form. When you open the form to edit the point (not create a new point), the date field is updated to the current date since the calculated expression is now(). Is there a way to not trigger the calculated expression if the field is already populated?

When I try to only update if the survey date field is null, I receive an Invalid DateTime error in the form.

//Arcade snip for calculating new date if the survey date field is empty

if (IsEmpty($feature.SurveyDate)) {
return now()
} else {
return $feature.SurveyDate
}

result

RobCahalan1_0-1675739767153.png

 

EDIT: This layer is from a feature service published from a SDE database. The survey date field is a Date type field.

0 Kudos
2 Replies
JohannesLindner
MVP Frequent Contributor

Try converting the existing date to Number:

if (IsEmpty($feature.SurveyDate)) {
    return Now()
}
return Number($feature.SurveyDate)

Have a great day!
Johannes
0 Kudos
RobCahalan1
New Contributor III

Good idea @JohannesLindner but unfortunately I am still receiving the "Invalid DateTime" in the smart form. I made an edit to my initial post adding in that the layer is from a published feature service in SDE...not sure if that is an issue here or not.

0 Kudos