Filter result from catalog client script

Eric148
Tera Guru

 

Hello,

 

When we went live with ServiceNow, our implementers created a Catalog Item for our Service Portal.  When a position code is entered on the form, an applications field is populated from a Catalog Client Script which reaches back to a Script Include to get the position code data.

 

What I have been asked to do is to filter the applications field to not include a keyword when it is populated on the Service Portal form.  Unfortunately, my Javascript is not quite up to speed on this.  Can anyone share what the best approach would be here?

 

Thanks in advance,

4 REPLIES 4

Brad Bowman
Kilo Patron
Kilo Patron

It sounds like you are saying the applications variable is automatically populated when the position code variable is populated.  Are you saying you don't want certain applications values to be automatically populated?

Hey Brad, that is correct.  For example, we want all applications to populate in on the form except for those that begin with Active Directory.

Post the contents of the Catalog Client Script and Script Include, and that will give me a better idea of what you're looking at.

Hey Brad, here you go.  If you need any additional info, just let me know.  Thanks again,

 

Script Include

var AccountRequestUtils = Class.create();
AccountRequestUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {

getFunctions: function() {
// get all functionality associated with this position code
var functionalityArray = [];
var poscode = this.getParameter("sysparm_poscode");
var gr = new GlideRecord("u_role_functions");
gr.addQuery("u_position_number", poscode);
gr.query();
while (gr.next()) {
functionalityArray.push(gr.sys_id.toString());
}
return functionalityArray.toString();
},

type: 'AccountRequestUtils'
});

 

Catalog Client Script

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}

if (newValue == '') {
g_form.clearValue(applications);
} else {
var ga = new GlideAjax("AccountRequestUtils");
ga.addParam("sysparm_name","getFunctions");
ga.addParam("sysparm_poscode", newValue);
ga.getXML(FunctionalityParse);
}

function FunctionalityParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue("applications",answer);
}
}