The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Bucket Group and Scripted Automated Indicator- Breakdown for empty vs. not empty

jlaps
Kilo Sage

Hello Community!

I am trying to create a breakdown for a group of existing indicators that will separate based on whether a field is empty or not. This is currently a text field, so it is not something I can use a normal breakdown for and have tried using a bucket group. I do not want to create additional indicators and stack them as there are many, and I am already doing some stacking- the breakdown method will be cleaner, but I think I am missing a step or just have a bad script.

I created a bucket group-

find_real_file.png

I created a breakdown source-

find_real_file.png

And finally I created an automated breakdown-

find_real_file.png

Unless I am missing a step, which is entirely possible, I think the problem is likely my script since I am a scripting neophyte- I have tried to create this based on what is OOB and some googling.

function empty() {
if (!u_peer_bundle)
	return '0';
else
	return '1';
}

When I run a collection, nothing is sorted into either the 0 or 1 buckets. Hoping it is something easy, or if someone has a better idea. Thanks!

Jeff

6 REPLIES 6

ChrisSteinke1
Kilo Expert

Hi Jeff. I think you just need to make two small changes - to bucket group and your script. 

For the bucket group, try this:

And for the script:

var result;

if ((current.u_peer_bundle == 0))

      result = 1;

else result = 2;

result;

 

I'm not an expert on scripting so please let me know if it doesn't work.

Regards,

Chris

 

Adam Stout
ServiceNow Employee
ServiceNow Employee

Don't mask the problem in PA. Fix the data in the base table (most likely by adding a true/false field).  This will allow you to simplify your breakdown but also allow you to use this:

  • In reporting
  • As an interactive filter
  • In a Business Rule
  • Any place else you may need it in the platform

 

If you have no other options, you should be able to fix your bucket definitions.  It should be null/blank to 1 and then 1 to null/blank.

Thank you for the reply Adam. Actually, there are reasons why I cannot add a field to the table. I would need to go down a change control route to edit the table, and we are on a partial freeze in that regard. I can however do whatever I wish with PA.

I tried changing the bucket group to null - 1 and then 1 - null, but get similar non-results when running a collection (no scores).

Thanks!

Jeff

Adam Stout
ServiceNow Employee
ServiceNow Employee

1) Taking the shortcut by using a script is fine for a quick response, but it is not a good long-term solution.  As long as you are OK with, let's get it to work.

2) What does your entire script look like?  It looks like you put in just a snippet of it.

3) Put in some gs.log() statements to make sure you are getting what you think you are getting in your script.