
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2024 02:19 AM
Hi,
I have return a GlideAJAX and ScriptInclude but I am getting [Object Object]. Both the variables are DropDown variables (Protocol and Type) in the main table (u_cmdb_ci_file_share). Kindly help.
GlideAJAX
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('ModifyNetworkSharePathClass');
ga.addParam('sysparm_name', 'ModifyNetworkSharePathFunction');
ga.addParam('passVariable', newValue);
ga.getXML(callBackFunction);
function callBackFunction(response){
var answer = response.responseXML.documentElement.getAttribute('answer');
var op = JSON.parse(answer);
g_form.setValue('share_type', op.sharetype);
g_form.setValue('protocol_type', op.protocoltype);
}
}
ScriptInclude
var ModifyNetworkSharePathClass = Class.create();
ModifyNetworkSharePathClass.prototype = Object.extendsObject(AbstractAjaxProcessor, {
ModifyNetworkSharePathFunction: function(){
var valuesShare = this.getParameter('passVariable');
var gr = new GlideRecord('u_cmdb_ci_file_share');
gr.addQuery('sys_id', valuesShare);
gr.query();
if(gr.next()){
var jsonOBJ = {};
jsonOBJ.sharetype = gr.u_type;
jsonOBJ.protocoltype = gr.u_protocol;
var json = new JSON().encode(jsonOBJ);
return json;
}
},
type: 'ModifyNetworkSharePathClass'
});
Regards
Suman P
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2024 04:22 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2024 02:35 AM
Hi @Community Alums
Can you try JSON.stringify in script include instead of encode and try.
Regards,
Sumanth

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2024 02:59 AM
Hi @SumanthDosapati,
I have changed it like this, still getting the same.
var ModifyNetworkSharePathClass = Class.create();
ModifyNetworkSharePathClass.prototype = Object.extendsObject(AbstractAjaxProcessor, {
ModifyNetworkSharePathFunction: function() {
var valuesShare = this.getParameter('passVariable');
var gr = new GlideRecord('u_cmdb_ci_file_share');
gr.addQuery('sys_id', valuesShare);
gr.query();
if (gr.next()) {
var jsonOBJ = {};
jsonOBJ.sharetype = gr.u_type;
jsonOBJ.protocoltype = gr.u_protocol;
// var json = new JSON().encode(jsonOBJ);
return JSON.stringify(jsonOBJ);
}
},
type: 'ModifyNetworkSharePathClass'
});
Regards
Suman P.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2024 03:43 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2024 03:49 AM - edited 11-14-2024 03:52 AM
Hi @Community Alums ,
in client script use answer = answer.evalJSON(); instead of JSON.parse.
Also check this blog, it will help you for better understanding about GlideAjax: https://servicenowwithrunjay.com/return-multiple-values-to-glideajax-from-script-include/
Please accept the solution if it helped.