Best way to get custom table value using Client Script

Maria20
Tera Guru

Hello SN Community!

So, I've created a custom table which stores field1 and the associated field2 value to be used on a Service Portal page.  Now, I'm trying to a use the value that the user selects for field1 to get and display the value of field2.  What is the best way to do this in an onChange client script?  I'm looking for best practices and possible samples, please....

Thanks in advance!

Maria.

1 ACCEPTED SOLUTION

Hi Maria,

Write an onchange Client script on field A;

Use g_form.getReference('field_name',callback) to get the server side value.

 

Update  field_2  from the custom table field name which stores (111) value and feild 2 in which you need to stores.

var g = g_form.getReference('fieldA',callback);
function callback(a){
g_form.setValue('field2',a.field_2);//Update field_2 with the field which stores 111 in yourcustom table
}

 

 

 

Mark helpful and correct if it helps.

Thanks,

CB

View solution in original post

6 REPLIES 6

I got it to work, CB!  Thanks! 🙂

Sudhanshu Talw1
Tera Guru

I recommend you to use glideAjax for this for calling script include via client script on the onChange event.

https://docs.servicenow.com/bundle/orlando-application-development/page/script/ajax/topic/p_AJAX.htm...

Thanks

Sudhanshu