Using a Dynamic Filter Option with an Interactive Filter

JamesLindsay
Giga Guru

I have a table where a row consists of multiple services listed in the cmdb_ci_service in a hierarchical order based on service classification, imagine L1, L2, L3-L6, etc. at each L level, the associated Owner (u_l1_owner) and Lead (u_l1_lead) is identified. So a row may look like:

This is the Service from cmdb_ci_service

Field
u_l1
Type
reference
Reference
cmdb_ci

, This is the service classification from the  cmdb_ci_service CI

Field
u_sc1
Type
string

,

Field
u_l1_owner
Type
reference
Reference
sys_user

,

Field
u_l1_lead
Type
reference
Reference
sys_user


As I said, each row repeats L1-L6 and all rows are unique.
I am trying to provide an interactive filter on a Dashboard that allows someone to pick a name and display all the rows where u_l1_owner is X or u_l2_owner is X or u_l3_owner is X of u_l4_owner is X or u_l5_owner is X or u_l6_owner is X.

I have created a script Include:

var ServiceStackUserFilter = Class.create();
ServiceStackUserFilter.prototype = {
    initialize: function() {},
    getStackByUser: function() {
        var userSysId = this.getParameter('sysparm_user_sys_id');
        if (!userSysId) {
            return '';
        }
        var qc = new GlideRecord('u_service_path');
        qc.addQuery('u_l1_owner', userSysId)
            .addOrCondition('u_l2_owner', userSysId)
            .addOrCondition('u_l3_owner', userSysId)
            .addOrCondition('u_l4_owner', userSysId)
            .addOrCondition('u_l5_owner', userSysId)
            .addOrCondition('u_l6_owner', userSysId);
        qc.query();
        var sysIds = [];
        while (qc.next()) {
            sysIds.push(qc.getValue('sys_id'));
        }
        if (sysIds.length > 0) {
            return 'sys_idIN' + sysIds.join(',');
        } else {
            return 'sys_id=NULL';
        }
    },
    type: 'ServiceStackUserFilter'
};

I have created a Dynamic Filter Option.
JamesLindsay_0-1759257436403.png

And I have created an Interactive Filter

 JamesLindsay_1-1759257506087.png

What I cannot figure out is how to align/use the dynamic filter option with the interactive filter. Everything I've tried shows the Interactive filter "Related list is empty" in the Dashboard. The only way I get anything is if I add an Interactive Filter Reference with the New UI action on the related list for the Interactive Filter.

JamesLindsay_0-1759259093033.png

However, adding them creates an AND condition for each field instead of an OR which is what the dynamic filter option is supposed to do for me. I just can't figure out how to get the three elements (Script Include, Dynamic Filter Option, Interactive filter) to work together. I have tested the script include and it returns the expected results. Maybe I'm just barking up the wrong tree entirely.
Any help and input is much appreciated.

0 REPLIES 0