Value before field updated

  • 1
  • Question
  • Updated 1 year ago
  • Answered
Is there a way to see the old value of a field just before update in javascript. The params passed to a snippet after field update list the new value but I do not see a way to access the old. Similarly to trigger.old and trigger.new, but with just one value.

I also did not see a way to do it with a custom skuid.event subscription. 

Example:

Field was changed from 10 to 15. I would like to access the old value of '10' 
Photo of Craig Rosenbaum

Craig Rosenbaum

  • 4,776 Points 4k badge 2x thumb

Posted 1 year ago

  • 1
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,704 Points 20k badge 2x thumb
The model has a property of something like originalValues that you can reference by field.
Photo of Craig Rosenbaum

Craig Rosenbaum

  • 4,776 Points 4k badge 2x thumb
Pat - you're exactly right. I was stuck on the event subscription I didn't think about going to the model. For anyone else looking for this, it is on the object and accessible through 'originals[rowId][fieldLabel]
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,076 Points 10k badge 2x thumb
Hey guys -

One thing to keep in mind that originals (formerly originalValues) is the original value of the field - not necessarily the value of the field prior to an update.  

If the field has been updated more than once, originalValues will not give you the 'before' value.  The purpose of this field is to support "Cancel Changes' which takes the row back to it's original state.  

I can't remember the argument values on model events but if the row updated doesn't have the before value, it would be nice to see that added.  Taking that thought process a step farther, would be nice to be able to cancel an update as well.  Ideally, a "beforeChange" event offering before value, after value and ability to return false to cancel the update.