Select to view content in your preferred language

Update Previous Inspection Date

763
3
Jump to solution
08-06-2023 09:48 PM
DMH_Hobart
Emerging Contributor

We have a field map that has a number of date / time attributes.

  • Current Inspection Date
  • Current Inspection Time
  • Previous Inspection Date 
  • Previous Inspection Time

If I change the current inspection date / time, how do I get the previous date / time to be the replaced by the old current date / time automatically?

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JustinReynolds
Frequent Contributor

Assuming you're creating and updating the same feature (not related records) you can you $originalFeature on Update.  $originalFeature contains the attribute values as they were last submitted to the database.

In this example I created two fields and added a form calculation to the the_previous_date field.

  1. the_current_date
  2. the_previous_date

Example: Using $originalFeature to access attributes from the previous form submissionExample: Using $originalFeature to access attributes from the previous form submission

 

// check the editType becuase $originalFeature isn't applicable on INSERT
if ($editcontext.editType == 'UPDATE') { 
  if (!IsEmpty($originalFeature.the_current_date)) {
    return $originalFeature.the_current_date;
  };
  // no previous inspection if current inspection date is null
};
// no previous inspection date on INSERT (new inspection)

 

And here is what it looks like:

calc_previous_date.gif

- Justin Reynolds, PE

View solution in original post

3 Replies
AndreasHall
Esri Contributor

I guess it might be possible to achieve what you want with Arcade but a better option would be to use a related table to store the inspections. Then you can easily keep the whole history of inspections in that table. Here is the first in a series of six videos outlining how to achieve this: Inspection Workflows Part 1: Building & Publishing Related Tables - YouTube

JustinReynolds
Frequent Contributor

Assuming you're creating and updating the same feature (not related records) you can you $originalFeature on Update.  $originalFeature contains the attribute values as they were last submitted to the database.

In this example I created two fields and added a form calculation to the the_previous_date field.

  1. the_current_date
  2. the_previous_date

Example: Using $originalFeature to access attributes from the previous form submissionExample: Using $originalFeature to access attributes from the previous form submission

 

// check the editType becuase $originalFeature isn't applicable on INSERT
if ($editcontext.editType == 'UPDATE') { 
  if (!IsEmpty($originalFeature.the_current_date)) {
    return $originalFeature.the_current_date;
  };
  // no previous inspection if current inspection date is null
};
// no previous inspection date on INSERT (new inspection)

 

And here is what it looks like:

calc_previous_date.gif

- Justin Reynolds, PE
DMH_Hobart
Emerging Contributor

Thanks @JustinReynolds , I appreciate you taking the time to assist with this 🙂