DirkRedeker
Mega Sage

Hi

In one of my previous articles, I wrote about using depending field with Reference Qualifiers. Now, if you just have simple conditions to cover, you may be served somewhat easier just configuring a "Dependent Field" in your Dictionary record for the given column.

That's "NO CODE - TO GO :-)"

 

Note:
You can find my previous Article by following the link below:

Article #4 - Depending Reference Fields - using Reference Qualifier

 

Scenario

I want to create a custom table (or new columns on an existing table works as well) having one field referencing to the CMDB CI table, but the reference should only show those CIs, that are in the same location as captured in a second custom field. See the screenshot for the desired result below:

  • The field "1st Rack" is a Reference Field to the "Location" [cmn_location] table
  • The field "Affected CI" is a List Field with a Reference to the "Configuration Item" [cmdb_ci] table

Having NO Location selected in the "1st Rack" field (1), I can see CIs from ALL Locations listed (3) in the Reference List for the "Affected CI" (2).

find_real_file.png

 

Having a Location selected in the "1st Rack" field (1), I can see CIs only from the same Locations listed (3) in the Reference List for the "Affected CI" (2).

find_real_file.png

BTW: This solution does not need any code or even Dictionary attributes to be configured 🙂

 

 

Steps to implement

 

STEP #1 - Create a Custom Table for the two fields

This is a custom table in Global Scope!

Note: This screenshot was made after I already added the two custom columns!

find_real_file.png

 

 

STEP #2 - Create the two fields

The first field/column "1st Rack" is the Reference to the "Location" table (the column "1st Rack")

find_real_file.png

find_real_file.png

 

 

The second field/column is the LIST type field with a Reference to the "cmdb_ci" table.

Note, that this field is NOT of type "Reference", but of Type "List" AND has the "Reference Specification" set up. That way, you will have the option to "reference" more than one record (just like you would with a simple "Reference" type field).

find_real_file.png

The next screenshot shows the "MAGIC" behind.

For the "List" field "Affected CI" (which has a "Reference Specification" to "Configuration Item" [cmdb_ci]), you just need to mark the "Use dependent field" Checkbox on the "Dependent Field" Tab (see screenshot below) AND select the field, that will be used to filter the selectable/available CIs in the Reference List for this column.

In my case, I want to make the available CIs depending on the Location selected in the "1st Rack" column (see screenshot below)

find_real_file.png

 

 

STEP #3 - Create some Test Data (2 CIs with Location = "Mexico")

For testing the results, I just changed the location of two CIs to "Mexico", and I will test my new table with that location.

The screenshot below shows the two CIs that I modified to work with my test-drive.

find_real_file.png

 

 

 

 

STEP #4 - TEST-DRIVE

Having NO Location selected in the "1st Rack" field, I can see ALL CIs listed in the Reference List for the "Affected CI"

find_real_file.png

 

As soon as I capture a Location in the "1st Rack" field, the Reference List for the CIs is limited to all CIs with the given Location!

find_real_file.png

 

Thank you for reading, and I hope you enjoyed this article.

Please provide your feedback on this article in the comments below.

If you like it, just mark this article as helpful and bookmark it using the "Bookmark" button above for later access.

Have fun and built something on ServiceNow

Dirk

---------------------------------------------------------------------

If you like to also review my other articles on the ServiceNow Community, please have a look at the overview here:

Overview of my articles

NOTE: The content I provide here is based on my own experiences and does not necessarily represent my employer's views.



 

Version history
Last update:
‎01-02-2021 11:43 PM
Updated by: