- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2016 06:49 AM
Hi All,
I am using script Include:
var Test_include = Class.create();
Test_include.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getIncident:function()
{
var str;
var category=this.getParameter('sysparm_caller_id');
var incs= new GlideRecord('incident');
incs.addQuery('caller_id',category);
incs.query();
while(incs.next())
{
str=incs.caller_id.first_name;
}
return str;
},
type: 'Test_include'
});
and Client Script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('Test_include');
ga.addParam('sysparm_name','getIncident');
ga.addParam('sysparm_caller_id',g_form.getValue('caller_id'));
//ga.addParam('sysparm_category',g_form.getValue('category'));
ga.getXML(HelloWorldParse);
function HelloWorldParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert('Answer:' + answer);
}
but the output showing NUll Values,Can anyone help on this.
Thanks in Advance,
Vardhini.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2016 05:29 AM
Exactly as I implemented it.
Are you using the Service Portal by any chance?
Client script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('Test_include');
ga.addParam('sysparm_name','getIncident');
ga.addParam('sysparm_caller_id',g_form.getValue('caller_id'));
ga.getXML(HelloWorldParse);
function HelloWorldParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('u_some_name', answer); // u_some_name is a field I created for testing purposes. The label of the field is "Some Name"
}
}
Script include:
var Test_include = Class.create();
Test_include.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getIncident:function() {
var str;
var category=this.getParameter('sysparm_caller_id');
var incs= new GlideRecord('incident');
incs.addQuery('caller_id',category);
incs.query();
while(incs.next())
gs.log('RajaV caller id is ' + category);
{
str=incs.caller_id.first_name;
gs.log('RajaV inc ' + str);
}
return str;
},
type: 'Test_include'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2016 10:27 PM
Hi Raja,
I rechecked the code and it works.
When you set the First name field in your client script - what does the code line look like?
It should be g_form.setValue('u_first_name', answer); //if your field's name is u_first_name
If that doesn't work, add the following lines to your script include:
while(incs.next())
gs.log('RajaV caller id is ' + category); //your name, so it is easy to filter for in the logs
{
str=incs.caller_id.first_name;
gs.log('RajaV inc str' + str);
}
Let me know of the results.
harel
By the way, onChange of which field?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2016 11:01 PM
Is the client callable checkbox checked on the script include ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2016 04:57 AM
Hi,
I checked Client callable in Script include and tied with the above code,
Still it is not working,
Harel can you show me the code how you did, I will reffer
Thanks,
vardhini
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2016 05:29 AM
Exactly as I implemented it.
Are you using the Service Portal by any chance?
Client script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('Test_include');
ga.addParam('sysparm_name','getIncident');
ga.addParam('sysparm_caller_id',g_form.getValue('caller_id'));
ga.getXML(HelloWorldParse);
function HelloWorldParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('u_some_name', answer); // u_some_name is a field I created for testing purposes. The label of the field is "Some Name"
}
}
Script include:
var Test_include = Class.create();
Test_include.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getIncident:function() {
var str;
var category=this.getParameter('sysparm_caller_id');
var incs= new GlideRecord('incident');
incs.addQuery('caller_id',category);
incs.query();
while(incs.next())
gs.log('RajaV caller id is ' + category);
{
str=incs.caller_id.first_name;
gs.log('RajaV inc ' + str);
}
return str;
},
type: 'Test_include'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2016 06:24 AM
Thank you Harel, It is working fine.