0% found this document useful (0 votes)
15 views

Dynamic Filtering of Reference Fields With Script Include and Reference Qualifier

Uploaded by

RICARDO FREITAS
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Dynamic Filtering of Reference Fields With Script Include and Reference Qualifier

Uploaded by

RICARDO FREITAS
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

DYNAMIC FILTERING OF

REFERENCE FIELDS
WITH SCRIPT INCLUDE
AND REFERENCE
QUALIFIER IN
SERVICENOW?
Does your reference field
display too many results,
making it hard for users to find
the right data?

With Reference Qualifier and


Script Include, we can
dynamically control which
values appear in a reference
field.

Let’s see how to do it!


WHAT IS A REFERENCE
QUALIFIER?

A Reference Qualifier is a feature in


ServiceNow that lets you limit the
results shown in a reference field.

You can choose from three options:


Simple, Dynamic, and Advanced,
each offering different levels of
control depending on the complexity
and context.
SIMPLE MODE – WHEN TO USE IT?

The Simple option allows you to limit


results using basic conditions set through
dropdowns quickly. It’s ideal for
straightforward scenarios where simple
filters like "Status is Active" or "Type is
Server" are sufficient.
Example: To display only active items in
the Configuration Item field, you can
easily set this up in Simple mode without
scripting.
Dynamic Mode

In Dynamic mode, you can choose from


predefined dynamic filter sets. These filters
are created by administrators and can
adjust results based on the user’s context.
Dynamic filters are useful when you want
data in the field filtered based on user
information like location or role.
Example: By setting the Reference
Qualifier to Dynamic, you can select a
filter that shows only CIs related to the
user’s location.
ADVANCED MODE

The Advanced option provides the most


flexibility, allowing for custom
JavaScript code. Here, you can use
Script Include to create complex
filtering rules. This is perfect for more
advanced scenarios requiring specific,
dynamic adjustments based on various
conditions.
Example: To display only active servers
in the Configuration Item field, you can
create a Script Include that dynamically
fetches these results.
EXAMPLE SCRIPT
INCLUDE CODE
STEP-BY-STEP GUIDE – SETTING
UP THE REFERENCE QUALIFIER

1. Choose the Configuration Item field:


Open the Configuration Item field
configuration (right click on the
field).
2. Select Reference Qualifier Type:
Simple: Set a basic filter using
dropdowns.
Dynamic: Choose a predefined
dynamic filter.
Advanced: Enter JavaScript, e.g.,
javascript: new
CIReferenceFilter().getActiveServers();
.

3.Save the field configuration.


When to Use Each Mode?

Simple: Ideal for basic filters, quick


and easy to set up.

Dynamic: Great for predefined


filters based on user or context.

Advanced: Best for complex


scenarios needing full control and
dynamic rules.
Reference Qualifier with Dictionary
Override

With Dictionary Override, you can set


different Reference Qualifiers for the
same field across various tables.

This allows you to adjust filtering for


the Configuration Item field, for
instance, on incident and
change_request tables, using different
conditions depending on the table.
STEP-BY-STEP GUIDE – SETTING A
DICTIONARY OVERRIDE

1. Open Configuration Item Field Settings:


Go to the Incident form, right-click on
the Configuration Item field, and select
Configure Dictionary.
2. Go to the Overrides Tab: In the
Dictionary configuration, scroll to the
Overrides tab at the bottom and click
on it.
3. Add or Edit an Existing Override: If an
override for the Incident table already
exists, you can edit it. If not, click New
to add a new override.
4. Select the Incident Table: Ensure that
the Table field is set to Incident.
5. Enable Override Reference Qualifier:
Check the Override reference qualifier
box to activate the ability to customize
the Reference Qualifier.
6. Add a Custom Reference Qualifier: In
the Reference qualifier field, enter
JavaScript code that specifies the filter
logic. For example:

7. Click Update or Save to save the


override configuration.
Using Dictionary Override makes it easy to
customize the way reference fields, such as
Configuration Item, are filtered for different
forms like Incidents.

This ensures users only see relevant data,


which speeds up their workflow and
enhances data accuracy.

Share your experiences and questions in the


comments!
I hope this information was helpful to
you.
If you want to share your experiences,
please write it in a comment - let's
learn from each other!
If you have any questions, write!

If you want more interesting


information, follow my profile.

Thank you :)

You might also like