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.

Bucket group and breakdown mapping via scripting

Timo Rasilainen
Kilo Explorer

Hi, I created a bucket group to classify users based on their email-addresses (User ID -field of sys_user table). I also created breakdown source using the newly created bucket group. Then I created breakdown for it, and set the mapping of it to use a script. Script runs through but not like I expect: All items go to last bucket, although they should split to all buckets.

Script is like:

var hr=function(x){
var rvalue=0;
if (x.includes("abc.com")) {
 rvalue=0; }
else if (x.includes("xyz.com")) {
 rvalue=1; }
else {
 rvalue=2;}
return rvalue;
};
hr(current);

I have set source to be sys_user and field= User ID. I assume that the problem is in parameter "current", which may not be a string value.

Can someone help me with this? Thanks in advance!

 

 

 

5 REPLIES 5

venori26
Tera Contributor

Issue: Scrited Breakdown have no affect on indicator scores

 

Scenario: I am trying a PoC the success of which would help me map bucket groups into scripted breakdown mapping.

 

table: incident

field: category

bucket group: Hardware, Software

 

Condition:

if category is any of (Network,Applications, Inquiry/Help) then it should display 'Hardware'

if category =(Database) then it should display 'Software'

else category

 

values in category field: Network, Applications, Inquiry / Help, Database, Software, Hardware

 

Breakdown mapping script:

 

var cat = function(x) {
var catvalue;

if (x == "Network" || x == "Applications" || x == "Inquiry / Help") {
catvalue = "Software";
}
else if (x == "Database") {
catvalue = "Hardware";
}
else {
catvalue = x;
}

return catvalue;
};

cat(current.category.toString());