How to get previous value of a reference field in an oncelledit client script?

prasanna11
Giga Guru

I have a requirement to determine the value of a reference field when edited on a list view and do some actions based upon their value.
I face a challenge to determine if the previous value was empty.

I see that there is an "OldValues" Parameter that comes along with oncelledit function. but 

OldValues.nil() > doesnt work

OldValues.toString() =='' > doesnt work 

Is there any way determine if the old value is empty in an oncelledit client script?

(i can think of a workaround to get sy id and query it using glideajax and retrieve the value of the field using script include but there has to be an easy way.)

Thanks in advance.

1 ACCEPTED SOLUTION

prasanna11
Giga Guru

oldValues was an array and oldValues[position number] works

View solution in original post

2 REPLIES 2

Mark Stanger
Giga Sage

You can use 'oldValues'.  Make sure that you use a lower-case 'o' as shown here...

https://docs.servicenow.com/bundle/helsinki-application-development/page/script/client-scripts/refer...

prasanna11
Giga Guru

oldValues was an array and oldValues[position number] works