The Zurich release has arrived! Interested in new features and functionalities? Click here for more

shouvik
ServiceNow Employee
ServiceNow Employee

The reference variable is for the User(sys_user) table. When you select a user, email and department from sys_user are copied to email and department variables. This could be a very common use case for all catalog admins. But what if I tell you that you can achieve the entire flow without writing a single line of code?

Let's see how we can use the power of Service Catalog and achieve this without writing a single line of code. The short answer to the magic is Catalog Data Lookup. Catalog Data Lookup lets you define a custom lookup table (extending dl_matcher). Then you can have the matcher define which can set the variable with values defined in the setter, when a valid match is found. But in the example we are using, the sys_user table that does not extend dl_matcher. So ho did the Data Lookup work?

How to configure Data Lookup

1. Go to System Definition > Tables > Data Lookup Definitions(dl_definition).

data look up definition.jpg

2. Under the Columns tab, select Matcher Table.

3. Under the Dictionary Overrides tab, click New. From Table drop-down list, select Catalog Data Lookup Definitions. Select the Override Attributes checkbox and then enter base_table=

dictionary overrides.jpg

4. Create a Catalog Item; for example, create a Test Item (Testing Lookup) with the following variables:

        a) Type:                   Reference

                Name:               requested_for

                Question:     Requested For

                Reference:     sys_user

        b) Type:                                                     Lookup Select Box

                  Name:                                               dept

                  Question:                                     Department

                  Lookup from table:       cmn_department

                  Lookup value field:       sys_id

                  Lookup label field(s): name

                  Include None:                       Checked

        c) Type:                               Single Line Text

                  Name:                         email

                  Question:                 Email

      catalog items.jpg

5. Create a Catalog UI Policy

        Name: Make Readonly

        Policy Action: Make Department and Email readonly

      Catalog ui policy.jpg

6. Navigate to System Policy > Rules > Data Lookup Definitions. Click New and select Catalog Data Lookup Rule.

data lookup rule.jpg

7. Create a Catalog Lookup Definition.

catalog lookup.jpg

8. Create a Catalog Matcher Variable Definition.

catalog matcher.jpg

9. Create Catalog Setter Variable Definitions.

variable definition.jpg

That is all! The catalog item is ready for the magic shown.

ezgif.com-video-to-gif (2).gif

Plugin required: Data Lookup and Record Matching Support for Service Catalog (com.glide.data_lookup.catalog).

This works on any field type, but the only limitation is that, Catalog Data Lookup works only on field change. So update your workflow to work with the field change. From Jakarta, the same setup works for Service Portal as well.

ezgif.com-video-to-gif (1).gif

4 Comments