Is it possible to display field value by combining two fields?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2019 07:39 AM
I have two fields on my form
1. Provider
2. Associated Phone Number
I want the third field "Name" to display by combining the value of these two fields
Example:
Provider = Sim
Associated phone number = 12345
Name = Sim - 12345
Can we achieve this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2019 02:17 AM
Can you please provide some solution to this.
Before saving the record if name field tries to display the value by combining from vendor and associated phone number, this will work fine.
Else it emerges out when i select the value of name on other forms

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2019 02:38 AM
hi
use this script
function onLoad() {
var r=g_form.getValue('u_provider');
var m=g_form.getValue('u_number');
var total=m+"-"+r;
g_form.setValue('u_name',total);
}
ur Associated phone number is a reference type then u can use
//g_form.getDisplayBox('u_number').value;
Thanks,
Rahul Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2019 02:44 AM
Hi Rahul,
I am able to get this result using business rule
but i have issue when i try to select this name information which is been calculated using this script, emerges out and shows invalid update when i save the record
Example:
I create a business rule to fill "name" field with the combination of "provider" and "associated phone number" This is in SIM table.
This associated phone number field is reference to a table called "Mobile phone"
If i now go to Mobile phone form and if i try to select the SIM name (Which is obtained from the script) it just emerges out (mean to say unable to select the value) and upon saving with blank it shows invalid update.
Can you please help (I even tried by disabling this script and entering the name value manually and selecting the name in mobile phone form, it allows me to select the value and save the record)
So i think this is the issue due to the BR created? Since it displays the name only on save
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2019 03:47 AM
I have created the Before business rule with your code, but nothing populated "onload", can you please help?
function onLoad() {
var r=g_form.getValue('u_provider');
var m=g_form.getDisplayBox('u_associated_phone_number').value;
var total=m+"-"+r;
g_form.setValue('name',total);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2019 09:14 AM
HI,
USe this code:
function onLoad() {
var r=g_form.getValue('u_provider');
var m=g_form.getDisplayBox('u_associated_phone_number').value;
var total=m.toString()+"-"+r.toString();
g_form.setValue('name',total.toString());
}
Thanks,
Ashutosh
ServiceNow MVP 2019
Please Mark Answer as Helpful or Correct Based on it's impact.