Select to view content in your preferred language

Auto populate Date only once on forms that are edited multiple times

336
4
07-26-2024 07:40 AM
LindsayLewin
Occasional Contributor

Hello.

I have a form that is edited by multiple users at various dates.  There are 3 groups and each group has a date field that needs to be populated.

I'd like the dates to be autopopulated, and I've used date() function for all three fields, however, if the form is opened again at another date, all the date fields from previous entries are changed the current date.

I need to retain the original dates - is there are way to do this?

Many thanks,

Lindsay

0 Kudos
4 Replies
KerriRasmussen
Esri Contributor

Hi Lindsay,

Good afternoon. You can use an Arcade expression on that field. I've included a sample below. You will need to update the name of your date field. This will capture the date when a new feature is added, but it will remain read only after that.

if ($editcontext.editType == "INSERT") {
   var originalDate = Today();

   //keep original date
   return originalDate;
} else {
  return $originalFeature.yourdatefield;
}
0 Kudos
LindsayLewin
Occasional Contributor

Worked like a charm!  Many thanks!

 

0 Kudos
LindsayLewin
Occasional Contributor

Hey Kerry - after adding some new data - with no dates recorded as of yet - i see that there is an issue with the code capturing that first date submission.  

If the field is null to begin with I need the user to submit that, then after retain that specific value throughout the lifecycle of the inspection.

I've tried to add a date() at the beginning of this expression with no luck - thoughts?

date()
if ($editcontext.editType == "INSERT") {
   var originalDate = Today();

   //keep original date
   return originalDate;
} else {
  return $originalFeature.SeedDate;
}

 

 

0 Kudos
LindsayLewin
Occasional Contributor

SO i figured this out - on features that are already exisiting, where the user is no actually creating new geometry - UPDATE is used instead of INSERT.

Thanks for getting me started on that one 🙂

if ($editcontext.editType == "UPDATE") {
   var originalDate = Today();

 

   //keep original date
   return originalDate;
else {
  return $originalFeature.SeedDate;
 
Lindsay.