
- 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 04:04 AM
Try debugging by logging the values of stringified object in script include.
Expected it should print Json as a string. If not then some issue in script include itself while constructing JSON object.
If still you are not able to find the issue then instead of JSON you can simply pass as a comma separated string and try.
Regards,
Sumanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2024 04:11 AM
Hi,
In your script include, try:
if (gr.next()) {
var jsonOBJ = {};
jsonOBJ.sharetype = gr.getValue('u_type');
jsonOBJ.protocoltype = gr.getValue('u_protocol');
return JSON.stringify(jsonOBJ);
}
getValue always return a string value.
gr.field is a gliderecord object - you cant expect a string to be returned just by dot.walk the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2024 04:20 AM
Hi @Simon Christens,
I am getting the proper value by changing this. However, there is an issue. I am getting sys_id for the reference variable. Kindly help.
var ModifyNetworkSharePathClass = Class.create();
ModifyNetworkSharePathClass.prototype = Object.extendsObject(AbstractAjaxProcessor, {
ModifyNetworkSharePathFunction: function() {
var valuesShare = this.getParameter('passVariable');
var jsonOBJ = {};
var gr = new GlideRecord('u_cmdb_ci_file_share');
gr.addQuery('sys_id', valuesShare);
gr.query();
if (gr.next()) {
jsonOBJ.sharetype = gr.u_type.getDisplayValue();
jsonOBJ.protocoltype = gr.u_protocol.getDisplayValue();
jsonOBJ.approver = gr.managed_by.toString();
// var json = new JSON().encode(jsonOBJ);
return JSON.stringify(jsonOBJ);
}
},
type: 'ModifyNetworkSharePathClass'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2024 04:22 AM
Change it from getValue to getDisplayValue
Regards,
Sumanth