- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2022 06:02 AM
Hello,
I want to auto populate the value of caller and created on by incident number on catalog item.(Please find attached Catalog form).
I have written below script code it is passing Null (What code line need to add for Populate Created on date).
Please help!
Script Include :
var Incidentrelatedinfo = Class.create();
Incidentrelatedinfo.prototype = Object.extendsObject(AbstractAjaxProcessor, {
infoincdt : function(){
var x = this.getParameter('sysparm_inc');
var gr=new GlideRecord('incident');
gr.addQuery('sys_id',x);
gr.query();
if(gr.get(x)){
return gr.caller_id;
}
},
type: 'Incidentrelatedinfo'
});
Catalog client script :
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var abc = g_form.getReference('caller_id');
var ga = new GlideAjax('Incidentrelatedinfo');
ga.addParam('sysparm_name', 'infoincdt');
ga.addParam('sysparm_inc', abc);
ga.getXML(pop);
function pop(response) {
var answer = (response.responseXML.documentElement.getAttribute('answer'));
alert(answer);
g_form.setValue('caller',answer);
}
}
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2022 06:10 AM
Hello,
You are trying to pass the caller id as a parameter but you need to pass the selected incident on the form
Please replace your client script as below
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('Incidentrelatedinfo');
ga.addParam('sysparm_name', 'infoincdt');
ga.addParam('sysparm_inc', g_form.getValue('your incident variable back end name'));
ga.getXML(pop);
function pop(response) {
var answer = (response.responseXML.documentElement.getAttribute('answer'));
alert(answer);
g_form.setValue('caller',answer);
}
}
Also replace your script include as below
var Incidentrelatedinfo = Class.create();
Incidentrelatedinfo.prototype = Object.extendsObject(AbstractAjaxProcessor, {
infoincdt : function(){
var x = this.getParameter('sysparm_inc');
var gr=new GlideRecord('incident');
gr.addQuery('sys_id',x);
gr.query();
if(gr.next()){
return gr.caller_id.toString();
}
},
type: 'Incidentrelatedinfo'
});
please mark my answer correct if it helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2022 06:10 AM
Hello,
You are trying to pass the caller id as a parameter but you need to pass the selected incident on the form
Please replace your client script as below
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('Incidentrelatedinfo');
ga.addParam('sysparm_name', 'infoincdt');
ga.addParam('sysparm_inc', g_form.getValue('your incident variable back end name'));
ga.getXML(pop);
function pop(response) {
var answer = (response.responseXML.documentElement.getAttribute('answer'));
alert(answer);
g_form.setValue('caller',answer);
}
}
Also replace your script include as below
var Incidentrelatedinfo = Class.create();
Incidentrelatedinfo.prototype = Object.extendsObject(AbstractAjaxProcessor, {
infoincdt : function(){
var x = this.getParameter('sysparm_inc');
var gr=new GlideRecord('incident');
gr.addQuery('sys_id',x);
gr.query();
if(gr.next()){
return gr.caller_id.toString();
}
},
type: 'Incidentrelatedinfo'
});
please mark my answer correct if it helps you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2022 06:14 AM
Hi Chandra,
You are passing caller id there.
Just change this line
ga.addParam('sysparm_inc', abc);
To
ga.addParam('sysparm_inc', g_form.getValue('incident_variable_name')); //give variable name of incident variable
Mark as correct and helpful if it solved your query.
Regards,
Sumanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2022 06:24 AM
Thanks for your reply.
What code line need to add (what line and where) for Populate Created on date for incident??