Scripted breakdown mapping with multiple return values

Dale Cameron
Giga Contributor

Can you have a script for a breakdown mapping return multiple SYS_IDs?

I have a use case where we want to breakdown incident indicators by the affected services (calculated by the associated CI).

This data is already being collected in a custom table, but the issue is that each incident can be related to/affect multiple services.

I tried return an array of sys_ids in a breakdown mapping script, but that didn't work.

Any Ideas?

1 ACCEPTED SOLUTION

Probably you need to use this hack:



Re: How to get the sys_id of the current record in an Indicator Script?



Besides I would change the script, like so:



function getImpactedServices(sys_id){


        var businesServices = [];


        var impactedservices = GlideRecord('task_cmdb_ci_service');


        impactedservices.addQuery('task', sys_id);


        impactedservices.addQuery('cmdb_ci_service.sys_class_name','cmdb_ci_service');


        impactedservices.query();


        while(impactedservices.next()){


                  businesServices.push(impactedservices.cmdb_ci_service);


        }


return businesServices;


}


getImpactedServices(current.sys_id);


View solution in original post

6 REPLIES 6

Alright thanks again arnoud . Your response got me there although didn't use the workaround described in the post. I didn't realize that sys_id wasn't available. I ended up just querying by incident number:


line 4:


impactedservices.addQuery('task.number', c.number);



I also tried to change the function to take a sys_id instead of current, but I get an error about:Not all references of "current" are passed in by "arguments" script:


Good, smart take you switched to number!