Client script gliderecord getEncodedQuery being ignored when using query('x','y')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2017 05:06 PM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2017 06:04 PM
Hi Shane,
Line 13 in encodequerystring i see space for Personal PC is this as expected ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2017 09:13 AM
Yes as the string result is exactly "Personal PC".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2017 10:29 PM
There is a space in below query. Encoded query will not have space
var encodedquerystring = "asset.u_computer_type=Personal PC^NQsys_class_name=cmdb_ci_peripheral";
// replace to below
var encodedquerystring = "asset.u_computer_type=PersonalPC^NQsys_class_name=cmdb_ci_peripheral";
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2017 09:13 AM
Would that then not return my result? The string is exactly "Personal PC".