You are viewing limited content. For full access, please sign in.

Question

Question

How to Retain "Last Updated" Values

asked on June 15, 2022

I'm in the process of adding a holding step at the very end of one of our processes used for reporting separations of employment. The holding step will allow the submitter to submit the form, but instead of it going straight to the repository, it will instead enter this holding step, allowing for them to potentially change the employee's last day without having to redo the entire form.

The holding step involves a user task, allowing for potential edits to the employee's last day to be made, until one day after the employee's last day, at which point I have set up a Timer Catch Event to bypass that step and save it to the repository.

If an edit is made, however, it sends an email and then loops back to the same user task, allowing for yet another date change to be made, if necessary.

What I'm looking to capture on the form itself is the effective date of the employee's separation as it originally was, as well as what it was changed to. If the form gets corrected a second time, however, I'd like the "original date" field to be updated to the first changed date, and the new date to also now be displayed. Not that this happens often, but I'd like to ability to repeat this process indefinitely. Ex:

First Correction
Original Date: 06/15/2022
New Date: 06/18/2022

Second Correction
Original Date: 06/18/2022
New Date: 06/25/2022

Third Correction
Original Date: 06/25/2022
New Date: 07/01/2022

Below is the relevant portion of the process diagram - hopefully this will help to better explain what I'm trying to do:


I thought setting a default value of "Effective Date" for the "New Date" field would always pull in the current value of the effective date upon loading the form, but it seems to always pull the first date ever entered into that field, never any subsequent updates to it. 

Any help would be greatly appreciated! Sorry this got confusing quick :D

0 0

Answer

SELECTED ANSWER
replied on June 15, 2022

You're not going to be able to achive this with built-in functionality to populate default values or lookup values.  Those only work on the first task where the form is assigned, once the values are populated, they won't be updated.

So you're going to need Javascript to achieve this.

Assuming you are using the Classic Designer, this should be fairly easy. 

Here's some Javascript that when the form loads, will copy whatever is in one field into the other field, meaning that if the form is saved, the new values are saved, but if it is just opened and closed without saving, then nothing changes.  This assumes you have added these two CSS Class Names to the fields: separationDate and oldSeparationDate.  

$(document).ready(function(){
  
  //When the form is loaded, copy the contents of the separationDate
  //field into the oldSeparationDate field, so that changes can be
  //viewed.
  $('.oldSeparationDate input').val($('.separationDate input').val());
  
});

 

0 0
replied on June 16, 2022

Matthew,

Thank you very much! This worked like a charm and I'm now able to achieve exactly what I had envisioned thanks to this. One of these days I really need to put in the time to learn JavaScript instead of just scrapping together other people's code. But in the meantime, I'm thankful those people exist! :D

1 0
replied on June 16, 2022

Glad to hear it worked!

0 0

Replies

replied on June 16, 2022

In a similar situation, I added a workflow task that populates a read-only multi-line log field on the form.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.