Record original value when date field changes
Hi everyone
I have a requirement where the history of a particular date field is recorded over time on a form. The field can be changed by the user but every time the date is changed I want to write the previous value in the date field to a text box on the form.
For example, if the date currently set is 1/1/2017 and the user then changes this date to 1/2/2017, 1/1/2017 is written to my text box. Is someone able to tell me the easiest way to do this please?
Many thanks for your help in advance.
-
Hi Gareth Jayne,
you can use the following calculated expression on the text field you want to have the previous value stored:
if([[Date.IsChanged]])
return [[Date]].format("d");
else
return [[Title.OriginalValue]];Cheers
Matthias
0 -
Thanks Matthias.
The above code works and puts the previous value for the date field into the text box when the date is changed. However, for some reason the format of the date isn't always the same:
- Sometimes when the date is changed the text box is populated in the format 31/08/2017
- Other times I change the date field and the previous date is then written into the text box in the format Mon Jan 9 00:00:00 UTC 2017.
Is there any reason you know of that could cause the format of the date to change like this? It seems to be completely random and is causing an issue as the change in format means that incorrect dates are being displayed.
0 -
Hi Gareth Jayne,
unfortunately I can't reproduce this behavior.. Can you recognize a regularity if it is always when you edit the date manually or just using the calendar or just on the edit form in a dialog or something like that?
This would be helpful to locate the problem.
BR Matthias
0 -
Hi Matthias
Apologies for the delay in coming back to you. The format issue is no longer happening and I think I've almost got what I need. The function of this has changed slightly to my original post but basically our users want to track the history of a date field every time it's changed. The code is shown below:
if([[Current_x0020_Implementation_x00.IsChanged]]){
return [[Current_x0020_Implementation_x00.OriginalValue]].format("d") + String.fromCharCode(13) + [[Implementation_x0020_Date_x0020_.OriginalValue]];
}else{
return [[Implementation_x0020_Date_x0020_.OriginalValue]];
}This successfully puts the original date into the text box but for some reason enters it five time as shown in the screenshot below:

I've used similar code to the above to record a comment history in the same form and this works with no issues. Can you see any issues in my code that could cause the date change to be recorded multiple times in the text box?
Thanks for your help in advance.
0 -
Hi Gareth Jayne
using skybow rich forms add-in I can reproduce your issue. When I try to reproduce it in our solution studio online (where we always have the latest version of Rich Forms before creating a new add-in version) it is working as expected.
There will be a new release version of the RF add-in in a couple of days. Maybe it will be solved there. I'm going to ask our QAs to test this, otherwise we need to take this as a story for a further version.
BR Matthias
0
Please sign in to leave a comment.
Comments
5 comments