com.glide.ui.ServletErrorListener error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2023 02:37 AM - edited 04-03-2023 02:42 AM
Hi All,
I have created a scoped application and created a table(SD Cases) within the app. Now I want to access the closed SDCases variable values and populate it on the form level when a closed SD case is selcted. Below are the scripts.
Client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
I have tried the above script include in the BGscript, it is returning the variable value but it is returning null when checked the alert in the client script.
Below is the
var ga = new GlideAjax('populatevariables');
ga.addParam('sysparm_name', 'demo');
var com = g_form.getDisplayValue('sd_number');
alert(com);
ga.addParam('sysparm_company', com);
ga.getXML(callBackFunction);
function callBackFunction(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
g_form.setValue('region', answer);
}
}
Script Include:
var populatevariables = Class.create();
populatevariables.prototype = {
demo: function() {
var company = this.getParameter('sysparm_company');
var gr = new GlideRecord('sd_case');
gr.addQuery('number', company);
gr.query();
if (gr.next()) {
var ans = gr.variables.region.toString();
return ans;
}
},
type: 'populatevariables'
};
Thank you in Advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2023 03:13 AM
It's a bit difficult to comment on anything else going on, but check your script include.
It seems to be a regular one, when it has to extend GlideAjaxProcessor to work with a client script.
There's a "Client callable" check box on the script include and clicking that should automatically modify your script include to match:
var PopulateVariables = Class.create();
PopulateVariables.prototype = Object.extendsObject(AbstractAjaxProcessor, {
type: 'PopulateVariables'
});
Also, it's good practice to name script includes with uppercase letters on each word and always return something from the function. For example false in this case and in your client script you can check "if(answer)" and it should not do anything if you're returned false. Then inside the if brackets you can keep your current answer handling code.
var PopulateVariables = Class.create();
PopulateVariables.prototype = Object.extendsObject(AbstractAjaxProcessor, {
demo: function() {
var company = this.getParameter('sysparm_company');
var gr = new GlideRecord('sd_case');
gr.addQuery('number', company);
gr.query();
if (gr.next()) {
return gr.variables.region.toString();
}else{
return false;
}
},
type: 'PopulateVariables'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2023 03:14 AM
Hi @Nagashree5 ,
I just modified the code a bit, please try with this code and make sure you have Client Callable check box enabled in the ScriptInclude. From the above ScriptInclude you pasted, I can see that, you haven't enablec Client Callable.
var populatevariables = Class.create();
populatevariables.prototype = Object.extendsObject(AbstractAjaxProcessor, {
demo: function() {
var company = this.getParameter('sysparm_company');
var gr = new GlideRecord('sd_case');
gr.addQuery('number', company);
gr.query();
var ans = 'No result';
if (gr.next()) {
ans = gr.variables.region.toString();
}
return ans;
},
type: 'populatevariables'
});
Thanks,
Anvesh
Anvesh