Is it possible to display field value by combining two fields?

Thrupthi
Tera Expert

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?

find_real_file.png

 

17 REPLIES 17

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

Rahul Kumar17
Tera Guru

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;

 

 

find_real_file.png

If my response helped please mark it correct and close the thread.

Thanks,
Rahul Kumar

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

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);
}

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.