- 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-15-2016 06:52 AM
This is where I start sticking gs.log() statements in my script included and ensure I'm getting the output I expect in System Diagnostics> Script Log Statements. Let's make sure the server side code is being called properly and returning what you expect.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2016 07:12 AM
Hi Raja,
Implemented it exactly as you have written, onChange of field assignment_group (just to test...)
I am getting the first name of the caller ID.
Can you make sure you don't have a typo in ga.addParam('sysparm_name','getIncident'); in your script? because that would return Null.
I also suggest changing while to if.
harel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2016 07:54 PM
Hi Harel,
Thanks for replying,
I tried by using IF , But Still Displaying [object,object] in First Name,
Can Any one check my code.
Thanks in advace,
Vardhini
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2016 08:01 PM