Creating a Dynamic Filter for HR SKills

GillianH
Tera Contributor

Hi all,

I'm trying to give agents a filter that reads "show me cases tagged with any of the skills on my own user record" — essentially a dynamic filter 'Skills is one of my skills'.  The operator does appear on the Skills field, so the option is binding. But after running the filter on a case list, the value renders null instead of One of My Skills. This happens for users with multiple skills, and in both native UI and Agent Workspace. 

the setup of skills field is:

Property Value
Tabletask (filtering child sn_hr_core_case)
Fieldskills
Typeglide_list
Referencecmn_skill
with the following script include:
var MySkillsFilter = Class.create();
MySkillsFilter.prototype = {
    initialize: function() {},

    getMySkills: function() {
        var skills = [];
        var gr = new GlideRecord('sys_user_has_skill');
        gr.addQuery('user', gs.getUserID());
        gr.addQuery('active', true);
        gr.query();
        while (gr.next())
            skills.push(gr.getValue('skill'));

        return skills.length ? skills : ['-1'];
    },

    type: 'MySkillsFilter'
};
 
The dynamic filter option record all looks correct, i believe the issue lies with the script include. Any guidance is greatly appreciated! 
 

 

3 REPLIES 3

sachinvic
Giga Guru

@GillianH 

 

Hi,

The Script Include looks reasonable, so there is no need to change it initially. Since the operator appears correctly but no skills are returned, start by checking the configuration and data flow.

 

Go to System Definition >> Dynamic Filter Options and verify the Script/Script Include, field type, referenced table, Active, and Available for filter settings.


Test getMySkills() for the affected user and confirm that it returns the expected skill sys_ids.
Check the user's records in sys_user_has_skill and confirm that the Skill is populated and Active = true. The Script Include is specifically filtering on the current user and active records.


Verify that the skills field on sn_hr_core_case references the same table as the Skill records returned by the Script Include.

 

If the Script Include returns the correct sys_ids but the filter still returns no results, focus next on the Dynamic Filter Option/reference configuration rather than changing the Script Include.

 

This should help isolate whether the issue is with the Dynamic Filter >> Script Include >> returned values >> reference field flow.

 

FYR: https://www.servicenow.com/docs/r/platform-user-interface/t_DynamicFilterOptions.html

 

GillianH
Tera Contributor

Hi, thanks for the troubleshooting steps. I’ve verified those parts:

- getMySkills() returns the expected sys_ids for the affected user.
- The user has active records in sys_user_has_skill, and each has a populated Skill.
- sn_hr_core_case.skills is a glide_list referencing cmn_skill, which is also the table referenced by the returned skill sys_ids.
- The Dynamic Filter Option is active, available for filtering, has no role restriction, and uses the glide_list field type.
A direct query against HR cases using those skill sys_ids returns matching cases.
The issue is that the is (dynamic) operator appears, but after I select the option, its value displays as null. So far, I haven’t confirmed whether that is only a display issue or whether the dynamic option is failing to resolve when the filter runs.

Has anyone seen this behavior with a Dynamic Filter Option on a glide_list field? Is there a specific return format or script-field syntax required for this field type? What’s the best way to verify whether the selected option is actually being evaluated?

Hi Gillian,

 

Since `getMySkills()` is returning the expected `sys_id` values and the same IDs return matching cases with a direct query, the Script Include itself looks fine.

 

The next step is to isolate the **Dynamic Filter Option + `glide_list`** behavior.

Try these checks:

1. Temporarily return a single known `cmn_skill` sys_id:

return ['<known_skill_sys_id>'];

2. If the Dynamic Filter still displays `null`, the issue is likely not the `GlideRecord` query.

3. Test the same Dynamic Filter Option against a normal **Reference** field to `cmn_skill`. If it works there but not with `sn_hr_core_case.skills`, that points toward a limitation/issue with the `glide_list` field.

4. Also confirm that the Dynamic Filter Option is configured with `cmn_skill` as the reference table and that the returned values are valid sys_ids.

The current approach of building an array with:

skills.push(gr.getValue('skill'));

is appropriate. There is no need to convert it to an encoded query such as `sys_idIN...` unless the Dynamic Filter specifically requires that format.

 

The single-sys_id test should help determine whether the problem is with the **Script Include return value** or with how the Dynamic Filter evaluates a **glide_list** field.


Helpful? Please mark the response as Accepted Solution ✅ and close the thread — this helps future readers find the solution faster.

 

Regards,
Sachinvic
✨ ArchX Certified | ✨ 16x ServiceNow AI MVP