- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2018 09:34 PM
Hi ServiceNow Gurus,
I have a reference field which we will call Field A. The field value is always "Digital" + "Value provided by requester". This will be saved to a table.
On load, I want to remove the word "Digital" and save it on a separate text field, called Field B.
Example:Field A: Digital Technology Advertisement
Field B: Technology Advertisement
My catalog client script is displaying the Field A sys_id to Field B.
function onLoad() {
var str = g_form.getValue('u_field_a'); // get value from Field A
var regex = str.toString().replace('Digital ', '');
g_form.setValue('u_field_b',regex); // save new value to Field B
}
Please help!
Thank you.
Carlo
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2018 10:13 PM
My bad, i didn't notice that it's returning the sys_id. Can you please something like this. Let's see if that helps.
function onLoad() {
g_form.setValue('u_field_b', g_form.getDisplayBox('u_field_a').value.substring(8));
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2018 09:38 PM
please try with,
var regex = str.substring(8);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2018 10:13 PM
My bad, i didn't notice that it's returning the sys_id. Can you please something like this. Let's see if that helps.
function onLoad() {
g_form.setValue('u_field_b', g_form.getDisplayBox('u_field_a').value.substring(8));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2018 10:21 PM
Works perfectly!
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2018 10:03 PM
Seems like field A is a reference type of field. Thats why sys_id is returning while you are using getValue method for field A.
In that case you have to use GlideAjax, GlideRecord or a getReference method to get the display value of field A.
Please go through the below link for an example.
Client Script returning sys_id instead of actual value.