Skip to main content

Search

Record original value when date field changes

Comments

5 comments

  • Matthias_Walter

    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
  • GarethJ1

    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
  • Matthias_Walter

    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
  • GarethJ1

    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
  • Matthias_Walter

    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.