CI based on location

Charls Brown
Tera Expert

Hello,

I want to bring all the CI´s based on location. On the incident form if a user select a location then all CI´s need to be filtered by that specific location. I have created a script include and I am calling with a reference qualifier on the Configuration Item field but for some reason its not working:

 

client callable

script include 

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


getConfigurationItems: function(ci_id) {

// if (!ci_id)
// return;
gs.log("Business Service ID: " + ci_id);
// Set up return value
var returnList = '';
// Get the Category Structures
var ci_gr = new GlideRecord('cmdb_ci');
ci_gr.addQuery('location', ci_id);
ci_gr.query();

while (ci_gr.next()) {
if (returnList == '') {
returnList += ci_gr.location.sys_id;
} else {
returnList += ',' + ci_gr.location.sys_id;
}
}

// gs.log("Return List: " + returnList);
// Return the values
return returnList;
},

type: 'SevenEleven_CI_ReferenceQuali'
});

 

Reference qualifier:

javascript:new SevenEleven_CI_ReferenceQuali().getConfigurationItems(current.location);

24 REPLIES 24

it doesnt work either

it shows all the CI´s  it doesnt do the filtering ;(

Hello Brown,

 

I have tried the same above piece of code in the background script and worked fine.

can you try adding the below highlighted logs and check what is going wrong ??

Reference Qualifier

javascript: var store = new SevenEleven_CI_ReferenceQuali().getConfigurationItems(current.location);

gs.info('Script Include Value'+store);

 

Script Include --> Client callable should be unchecked

getConfigurationItems: function(ci_id) {

gs.info('inside Function');

gs.info('Value of ci_id'+ci_id);

 

var returnList = [];
// Get the Category Structures
var ci_gr = new GlideRecord('cmdb_ci');
ci_gr.addQuery('location', ci_id);
ci_gr.query();

while (ci_gr.next()) {

gs.info('<<Location>>'+ci_gr.location);
returnList.push(ci_gr.location)
}

return returnList.toString();

},

Jim Coyne
Kilo Patron

There's a much simpler way of doing it without a Script Include:

find_real_file.png

Did you try without the Script Include?