Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2024 02:28 AM
Hey Folks,
I'm just learning and practising development, I'm unable to complete the Script include & client script, need your help.
Can someone help with what went wrong
Script Include :
var getIncDetails = Class.create();
getIncDetails.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getINC:function(){
var incArray = [];
var gr = new GlideRecord('incident');
gr.addQuery('caller_id',this.getParameter(sysparm_user_id));
gr.query();
while(gr.next()){
var incDetails = {};
incDetails.number=gr.number.toString();
incDetails.priority=gr.priority.getDisplayValue();
incDetails.short_desc=gr.short_description.toString();
incArray.push(incDetails);
}
return JSON.stringify(incArray);
},
type: 'getIncDetails'
});
Client Script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var finalArray = [];
var ga = new GlideAjax('getIncDetails');
ga.addParam = ('sysparm_name','getINC');
ga.addParam = ('sysparm_user_id',newValue);
ga.getXMLAnswer(IncDetail);
function IncDetail(response){
var obj = JSON.parse(response);
for(var i =0;i<obj.length;i++){
finalArray.push('Incident Number : '+ obj[i].number +'\n'+'Priority : ' + obj[i].priority +'\n'+ 'Short Description : ' + obj[i].short_desc +'\n\n');
}
// g_form.setValue('description',finalArray);
g_form.setValue('description',finalArray);
}
//Type appropriate comment here, and begin script below
}
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2024 11:08 AM
Hi @abjaffrey
ga.addParam = ('sysparm_name','getINC');
ga.addParam = ('sysparm_user_id',g_form.getValue('caller_id'));
Change these two lines as below in client script
ga.addParam('sysparm_name','getINC');
ga.addParam('sysparm_user_id',g_form.getValue('caller_id'));
12 REPLIES 12
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2024 07:45 PM
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2024 07:54 AM
@abjaffrey did you check the logs to see if the script include logs the incArray?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2024 07:41 PM