Access request item variables through client script

manredd
Kilo Expert

function onChange(control, oldValue, newValue, isLoading) {

if (isLoading) {

  return;

}

var Emp = new GlideRecord('sc_req_item');

Emp.addQuery('sys_id', newValue);

Emp.query();

while(Emp.next()) {

  g_form.setValue('u_first_name', Emp.variables.u_first_name);

    }

}

i used this code but this gives me undefined in my coloumn

1 ACCEPTED SOLUTION
14 REPLIES 14

nikita_mironov
Kilo Guru

Hi


Variables can not be accessed from a Client Script even using very limited GlideRecord object.


You should use Clien-Callable Script Include called through GlideAjax. You pass paramters and get the result of teh server processing. See more here:


GlideAjax - ServiceNow Wiki


Regards


Nikita


Chuck Tomasi
Tera Patron

Hi Manohar,



Your onChange client script, what table/field is it reacting to? I'm trying to determine what newValue is supposed to be.


its a sysid of request item(sc_req_item)


Thank you. I recognized that it was a sys_id of a request item (or supposed to be) from the query. What table is your client script running on and what field is it set to?



For example:



find_real_file.png