Implementation of Data Lookup Table in ServiceNow


Data Lookup Rules 

Data Lookup Rules are an essential component of ServiceNow that is often overlooked. While it's possible to use hardcoded scripts to implement auto-mapping, data lookup tables provide an easy-to-use alternative. With data-driven design, developers can increase the velocity of their development and reduce the amount of maintenance required for future configurations/customizations. So, whether you're a developer or an admin, consider using Data Lookup Rules to auto-populate values based on other field values. It's a simple but powerful tool that can make a big difference in your workflow.

Let's say you have the following business requirements:

Auto-populate Hotel Category based on Employee Department & Employee Title

But before jumping straight into the implementation, let me provide you with a little bit more context. 

This is the form of a Hotel Booking custom app:

As you can see in the image marked in red, these are the fields on which the data lookup table rule needs to run or execute. In other words, if I select the Employee Department as IT and the Employee Title as Director, then the Hotel Category field should automatically populate: 5-Star 

That's the context.

Now, the question is: how to achieve this with Data Lookup Rules?

STEPS

CREATE DATA LOOKUP TABLE

  • Navigate to Tables
  • Create a new Data Lookup Table (Hotel Lookkup Definition)

IMPORTANT: your table must extend the Data Lookup Matcher Rules (dl_matcher) table which already contains some existing functionality
  • Add the necessary fields that you want to apply the data lookup rules
  • In our case, we have added three fields: Employee Department, Employee Title, and Hotel Category
CREATE DATA LOOKUP RULES (RECORDS)
  • To make the data lookup table rules work, you need first to create a few records in the Hotel Lookup Rules table
  • For instance, if Employee Department = IT & Employee Title = Director, then set Hotel Category to 5 - Star, etc.
CREATE DATA LOOKUP DEFINITIONS
  • Navigate to Data Lookup Definitions

  • Click New
  • Provide a Name
  • Select the right Source Table
  • Select the correct Matcher Table
  • Select Run on update checkbox
  • Click Submit
  • Note: Data Lookup Definitions is a system table that says “How do you want me to work”
DEFINE MATCHER FIELD DEFINITIONS
  • In the new data lookup definition (Hotel Lookup Rules), you need to define your Matcher Field Definitions

  • Click on New
  • Provide a Name
  • Select the Source table field
  • Provide Matcher table field
  • Select Exact lookup match
  • Click Submit

This is the definition of the Employee Title. Create a second definition for the Employee Department.
The two Matcher Field Definitions are what need to match. In other words, it says that when the Employee Department is IT and the Employee Title is Director, then there is a match.

Next, is what do you want to do with that?

DEFINE SETTER FIELD DEFINITIONS
  • In the Setter Field Definitions, you can set up what to do:

  • In our case, we define the Hotel Category rule:

  • Which will automatically populate the Hotel Category based on the Matcher Field Definitions
  • KEY TAKEAWAY: the matcher & setter field definitions MUST be on the same table
Last but not least, TEST if it’s working!


TLDR
  • Create a new table - Data Lookup Table (Hotel Lookkup Definition)
  • Extend it from Data Lookup Matcher Rules (Data Lookup Matcher Rules)
  • Add fields for the matcher & setter field definitions
  • Create new data lookup rules (records)
  • Create the Data Lookup Definitions (matcher & setter field definitions)
  • The system will automatically then look at the data lookup rules table to apply those rules for the matcher & setter field definitions

That's a wrap!

Remember: always push your limits!


References:
  • https://www.youtube.com/watch?v=YAAOAN9KTJs&ab_channel=ServiceNowCommunity
  • https://www.youtube.com/watch?v=pMmwgtNHDCs&ab_channel=CIELOServiceNow%2CAWS%2CNetworking


Comments

Popular Posts