Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Script for breakdown mapping not working

venori26
Tera Contributor

I am trying to group certain elements based on a condition.

 

Table: cmdb_ci

Field: Class

 

Condition:

 

If data in Class starts with 'Computer' then 'Hardware'

If data in Class starts with 'Windows' then 'Software'

else 'Other'

 

Script & Error:

Error during JavaScript evaluation: Not all references of "current" are passed in by "arguments" script:

var getCIGroup = function(ciClassValue) {
var type = 'Other';

if (!ciClassValue)
return 'No CI Linked';

var cleanValue = ciClassValue.trim().toLowerCase();

if (cleanValue.indexOf('computer') === 0) {
type = 'Hardware';
} else if (cleanValue.indexOf('windows') === 0) {
type = 'Software';
}

return type;
};

var result = function(current) {
if (!current.cmdb_ci) {
return 'No CI Linked';
}

var ci = new GlideRecord('cmdb_ci');
if (ci.get(current.cmdb_ci.toString())) {
return getCIGroup(ci.Class + '');
} else {
return 'CI Not Found';
}
};

result(current);

0 REPLIES 0