Onchange Client script previous value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-23-2020 04:01 AM
Hello,
Is there a way to catch the previous value of a Onchange client script ?
Not the oldValue (first value after a page load) by the previous value after the newValue ?
I did that with a custom field "previous value" who copy the newValue every time to compare with the value of the field "previous value".
It works well by I would like to know if there is a better way to do that stuff. (I don't wont to create fields everytime I need a previous value ;-))
Thanks a lot for your help.
Regards,
- Labels:
-
Team Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-23-2020 08:57 AM
Hi Ben,
I don't think using the client script you would get that directly
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2020 03:07 AM
Hi Ben,
Have you tried adding scratchpad in the end of the onChange Client Script to store the previous value?
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
var previousValue;
if (g_scratchpad.previousValue == undefined){
previousValue = oldValue;
}
else{
previousValue = g_scratchpad.previousValue;
}
g_scratchpad.previousValue = newValue;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2021 01:08 PM
Thanks Arth,
This was really Helpful.