Select to view content in your preferred language

Auto populate Date in a field and keep that date the next time the smart form is opened

149
5
Jump to solution
a week ago
ChristineTombleson1
Frequent Contributor

Hello - I have field in a smart form in Field Maps that uses a calculated expression of Now() to auto populate the current date.   However, when a user goes back to the form to review on another day, I don't want the current date populating. I want the original date to remain in the field. This is meant to be a read only field that populates the date a feature was created and keeps that date.  When I go into edit the feature, the date keeps changing to the current date.  How can I fix this?  Thank you.     

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
LeeButler
Esri Contributor

You could try using the IsEmpty function to only input the current date when the date field is empty. If the date field already has a value then you can return this so the date isn't updated:

 

var dateField = $feature.Date //Change this to your date field

if (IsEmpty(dateField)){
  return Now()
}

else {
  return dateField
}

View solution in original post

5 Replies
Eugene_Adkins
Frequent Contributor

You could remove the calculated expression and force the user to manually enter the date. Once the date is entered it will remain unchanged. Another option is to enable editor tracker so the original creation date is captured without any direct input required from the user. You could make the creation date a field that is not viewable (or viewable if you wish) in the form but the date will still be captured.

Someone else may have a more useful idea but these are simple ones. Hope they help.

0 Kudos
LeeButler
Esri Contributor

You could try using the IsEmpty function to only input the current date when the date field is empty. If the date field already has a value then you can return this so the date isn't updated:

 

var dateField = $feature.Date //Change this to your date field

if (IsEmpty(dateField)){
  return Now()
}

else {
  return dateField
}
ChristineTombleson1
Frequent Contributor

Thank you for the guidance!

I put the following in the Calculated expression for my SiteCreationDate field on my Field Maps Smart Form:

 var dateField = $feature.SiteCreationDate //Change this to your date field


if (IsEmpty(dateField)){
  return Now()
}

else {
  return dateField
}

However, every time I go to view or select edit to open up a Field Map Smart Form, the current date is still being populated in the SiteCreationDate. 
 
0 Kudos
ChristineTombleson1
Frequent Contributor

Thank you, I got this to work in Survey123, do you know how to construct the expression for use on a Field Maps Smart Form?  I have tried this, but it is not working: 

DefaultValue($feature.SiteCreationDate, Now())
0 Kudos
ChristineTombleson1
Frequent Contributor

Thank you, you solved my issue!  I really appreciate the help 🙂