This topic is locked
[SOLVED]

 Old value on 'change' field event

2/25/2018 6:35:10 AM
PHPRunner General questions
S
Scrolin author

Is is possible to obtain the old value of a field when a change field event fires?
and (subtle difference)
When a field is changed for a 2nd or subsequent time, can the change field event obtain the original value?
Thanks in advance

S
Scrolin author 2/25/2018

Have found the answer to my 2nd question
The original value is

field.defaultValue

( or

this.defaultValue

in its own field event)
I'd still like to know the answer to the first question though

S
Scrolin author 2/28/2018

Experimentation has shown that it is safe to change defaultValue so it can be used to store the most recent change (thereby losing the original value)

At the end of the change field event client code(either the Client Before or Client After function) add the following

this.defaultValue=this.getValue();


Experimentation has also shown that this does not affect the $oldvalues array when the record is changed/stored
What it does mean is that if you want to know both the original value and the most recent change prior to the current change you will have to use the Server function to retrieve the original value.