How to get reference field values in another field.

shravani6
Tera Contributor

On the catalog request form, I have 3 reference fields and those fields' values should display in the 4th field with (,) comma-separated and 4th filed is a single-line text.

find_real_file.png

 

also tried this catalog client script it is displaying sys_id in the 4th field.

find_real_file.png

1 ACCEPTED SOLUTION

RaghavSh
Kilo Patron

Try:

g_form.getDisplayBox('variable_name').value instead of g_form.getValue


Raghav
MVP 2023

View solution in original post

6 REPLIES 6

Jaspal Singh
Mega Patron
Mega Patron

Can you use

var avzone1=g_form.getDisplayBox('subnet_1_av_zone').value;

var avzone2=g_form.getDisplayBox('subnet_2_av_zone').value;

var avzone3=g_form.getDisplayBox('subnet_3_av_zone').value;

Also, ensure Isolate script (not available on Form OOB but can be added or edited from List Layout) field on the Client script is set to True

RaghavSh
Kilo Patron

Try:

g_form.getDisplayBox('variable_name').value instead of g_form.getValue


Raghav
MVP 2023

Ankur Bawiskar
Tera Patron
Tera Patron

@shravani 

this should work in both native and portal

    if(window == null){
		var avzone1 = g_form.getDisplayValue('subnet_1_av_zone');
        var avzone2 = g_form.getDisplayValue('subnet_2_av_zone');
        var avzone3 = g_form.getDisplayValue('subnet_3_av_zone');
		var zone = 	avzone1 + "," + avzone2 + "," + avzone3;
        g_form.setValue('subnet_availability_zone', zone);
	}
	else{
		var avzone1 = g_form.getDisplayBox('subnet_1_av_zone').value;
        var avzone2 = g_form.getDisplayBox('subnet_2_av_zone').value;
        var avzone3 = g_form.getDisplayBox('subnet_3_av_zone').value;
        var zone = 	avzone1 + "," + avzone2 + "," + avzone3;
        g_form.setValue('subnet_availability_zone', zone);		
	}

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

shravani6
Tera Contributor

Thanks, Ankur it is working as expected.