how to pass sys ids from script include to client script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2021 11:08 AM
There is a variable on a caltalog item named "IP" which is a reference field....I am stucked at client script...can anyone please help me...
Script Include
var Firewall_IP = Class.create();
Firewall_IP.prototype = Object.extendsObject(AbstractAjaxProcessor, {
PopulatIPsBasedonLoc: function() {
var Loc = this.getParameter('sysparm_location');
var gr = new GlideRecord('ip_address');
gr.addQuery('location', Loc);
gr.query();
var answer = [];
while (gr.next()) {
answer.push(gr.sys_id.toString());
}
return 'sys_idIN' + answer;
},
type: 'Firewall_IP'
});
OnChange Client Script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 'IP') {
var grLocation = g_form.getValue('source_location');
var ga = new GlideAjax('Firewall_IP');
ga.addParam('sysparm_name', 'PopulatIPsBasedonLoc');
ga.addParam('sysparm_location', grLocation);
}
//Type appropriate comment here, and begin script below
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2021 11:18 AM
Hi,
Not sure what you want to do with the response but you can use getXML() and getXMLAnswer() to get the response from the script include:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 'IP') {
var grLocation = g_form.getValue('source_location');
var ga = new GlideAjax('Firewall_IP');
ga.addParam('sysparm_name', 'PopulatIPsBasedonLoc');
ga.addParam('sysparm_location', grLocation);
ga.getXMLAnswer(function(answer){
//answer is your returned value
console.log(answer);
});
}
//Type appropriate comment here, and begin script below
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2021 11:23 AM
hi,
as i mentioned above there is a variable on a catalog item which refers to IP table....
now the returned sysids I need to store in this variable.. can you please update my client scrpt accordingly

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2021 11:26 AM
If the field is just called IP, you can do this:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 'IP') {
var grLocation = g_form.getValue('source_location');
var ga = new GlideAjax('Firewall_IP');
ga.addParam('sysparm_name', 'PopulatIPsBasedonLoc');
ga.addParam('sysparm_location', grLocation);
ga.getXMLAnswer(function(answer){
//answer is your returned value
g_form.setValue('ip' , answer);
});
}
//Type appropriate comment here, and begin script below
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2021 11:46 AM
so as part of debubbing I have kept alert in the client script for answer...then I got output like below..
sys_idIN025c3e18db356g6734a7b062f396197d,3cb44c6c345tg650965917a94b96192d
please help me to fix this