Client Script: Get value from another table

ceraulo
Mega Guru

Hello!

I have a custom table containing 3 text fields: field_a, field_b, field_c.

In the incident form, I have a reference field called "field_aa" which pulls the data from the custom table.

I have 2 other custom reference fields in the incident form called 'field_bb' and 'field_cc'. I would want these fields to populate when field_aa changes.

ServiceNow version is Kingston.

Please help!

Thank you.

4 REPLIES 4

Harsh Vardhan
Giga Patron

you can use call back function on your onChange() client script.

 

eg:

 

var fielda= g_form.getReference('field_aa', doAlert); // doAlert is our callback function

function doAlert(fielda)
{
//reference is passed into callback as first arguments
alert(fielda.field_bb +fielda.field_bb);

}

change the field according to the exact field name that you have.
just give a try

if it will not work then i would suggest to write glideajax to retrive the other columns value.

Hi there. I've tried that and it did not work. 😞

How do I use glideajax to retrieve the column value?

kindly refer the doc link below.

 

https://snprotips.com/blog/2016/2/6/gliderecord-client-side-vs-server-side

 

https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/script/server_scripting/reference...

 

just give a try with basic if you are new in glide ajax. 

go with doc link . build you script if you stuck let us know

Ahmmed Ali
Mega Sage

Hello,

 

you can use glideajax to retrieve data from service side. 

create a script include to query the custom table with parameters sent by client script and return other two field details.

have a onchange client script on field_aa and send the field value as parameter for script include.

 

Please refer below link for more details on glideajax.

https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/script/server_scripting/reference/r_ExamplesOfAsynchronousGlideAjax.html

 

Thanks,

Ali

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali