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

jordanguitt
Tera Contributor

Hello everyone!

 

Several users are tired of having to select a large number of different products in the filters of my dashboard.

So I'd like to set up a new ProductGroup breakdown, so that only one box needs to be checked, rather than 15.


To do this, I've created a new ProductGroup bucket. This bucket currently contains only two records, but this will evolve over time:
0 = Other
1 = Group1

I was able to create the corresponding source breakdown and breakdown.
However, when I try to do the breakdown mapping, it seems that I need to use a script to be able to do the grouping.


Here's my script:

var getProductGroup = function(GP)
{
var type = 0; //other

const validGPs = [
“Product1”,
“Product2”,
“Product3”,
];

// Clean up GP value: remove superfluous spaces and convert to lower case
if (validGPs.map(gp => gp.toLowerCase()).includes(GP.trim().toLowerCase()) {
type = 1;
}

if(GP == “AI Training”
|| GP == “Public Cloud Load Balancer”)
type = 1;

return type;
};
getProductGroup(current.product);


This script doesn't work, because when I apply my filter on my dashboard, all my tickets are listed in the “Other” group, even though I do have tickets open with Product1, Product2, Product3

 

I've been trying to figure out why this isn't working for a while now.
I've tried using an existing script, which works fine:

var getLoSGroup = function(LoS)
{
var type = 0; //other

if(LoS == “Level1”
|| LoS == “Level2”)
type = 1;

return type;
};
getLoSGroup(current.ticket_u_level_of_support);


I've modified this script to suit my use case:

var getProductGroup = function(GP)
{
var type = 0; //other

if(LoS == “Product1”
|| LoS == “Product2”)
type = 1;

return type;
};
getProductGroup(current.product);


This script is based on a working script, and yet it doesn't work. I always end up with all my tickets categorized in Other, even though I have tickets open for Product1.

Can anyone help me find the source of the problem in my script?

Note: to find the (current.product) I just used the field used on the breakdown mapping


Thanks to all

0 REPLIES 0