how to pass sys ids from script include to client script:

Sathwik1
Tera Expert

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

}
19 REPLIES 19

Not via a client script. You'll need to handle the logic in the script include by checking the passed value and either returning nothing or your filter.

Not sure what you said, can you suggest me whether my requirement is possible or not... if possible can you please help me with the script

@Ankur Bawiskar @Shivani Singh 

Hey Sathwik,

Check if you got the solution and if not then can you please explain me in one reply or another question. everything in consolidated format

 

Quite a long thread to go through

No, you can't achieve what you want via a client script. You have to use a reference qualifier to change what records are visible in a list collector or reference field.

var Firewall_IP = Class.create();
Firewall_IP.prototype = Object.extendsObject(AbstractAjaxProcessor, {
	PopulatIPsBasedonLoc: function(location) {
		if(location != 'IP')return;
		var gr = new GlideRecord('ip_address');
		gr.addQuery('location', location);
		gr.query();
		var answer = [];
		while (gr.next()) {
			answer.push(gr.sys_id.toString());
		}
		return 'sys_idIN' + answer;
	},
	type: 'Firewall_IP'
});