
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2020 01:15 PM
When a reference field (sys_user) is changed, the request is to enter work notes with old value and new value
I cannot seem to figure out how to use the oldvalue (sys_id) to query the Sys_User table
Here is what I have that isn't working- no alert appears
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var gr = new GlideRecord('sys_user');
gr.addQuery('name', oldValue);
gr.query(myCallbackFunction); //Execute the query with callback function
//After the server returns the query recordset, continue here
function myCallbackFunction(gr){
while (gr.next()) { //While the recordset contains records, iterate through them
alert(gr.user_name);
}
}
//HAVE NOT YET UPDATED
g_form.setValue('work_notes', "Financial Approver changed from " + oldValue + " to " + newValue);
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2020 01:21 PM
Hi,
1) Why you want to do this using script. Just add the field in activity log same as state field using funnel icon. Which will show you value transition from old to new.
2) You have to write a script include and pass the oldValue sys_id there to get name.
Thanks,
Ashutosh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2020 01:21 PM