Client script gliderecord getEncodedQuery being ignored when using query('x','y')

SC10
Kilo Guru

I noticed that while the following onchange client script is working, my getEncodedQuery is being ignored (no errors!) when using a normal query('x','y').

Code is as follows:

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

  if (isLoading || newValue === '') { //Return out of this script when the form is initially loading (isLoading) or the new field value from "Field name" above is blank

  return;

}

  g_form.setValue('u_ci_list', ""); //Start with blanking out the asset list

  populate_ci_list();

  function populate_ci_list(){

  var gr = new GlideRecord('cmdb_ci'); //Call the cmdb_ci table

  var caller = g_form.getValue('caller_id'); //Grab the caller_id value

        var encodedquerystring = "asset.u_computer_type=Personal PC^NQsys_class_name=cmdb_ci_peripheral";

        gr.addQuery('assigned_to', caller); //Add a query of the 'assigned_to' field to the gr call

  gr.getEncodedQuery(encodedquerystring);

        gr.query(); //Do the query to the gr call

  while(gr.next()) //Loop through the alm_asset table, which includes the query from above

  {

  g_form.setValue('u_ci_list', gr.sys_id); //When finding a matching item in the table with the query, set the 'u_assets' field to the data returned from the query

  }

  }

}

Any ideas?

10 REPLIES 10

Also if you want to go an unsupported way, client GlideRecord is not protected as server side, so you can simply set the value of the encodedQuery property like this:



gr.encodedQuery = encodedquerystring;