Catalog Data Lookup Definition on any table, eliminating Catalog Client Scripting
Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
Hi there,
Working often with Service Catalog? You probably come across wanting to populate Variables onChange depending on a different Variable. Up to the Paris release, the best answer would be to use a Catalog Client Script which uses GlideAjax (with getXMLAnswer). Other possibilities like getReference would be possible, though are the kiddy solutions.
Though why do we always need to script this?! Well with the Quebec release… Eureka! The Release Notes mentions "Eliminate scripting by leveraging data lookup rules that can now be set on any table within the current scope."
(Small note to this, this does concern data lookups on the same table)
Let's get after it!
Catalog data lookup definition
Say what? Catalog data lookup definition? You might have heard of Data lookup definitions within the Platform, though actually, these are also available for the Service Portal. Catalog data lookup definition has been added with the Paris release, one thing though… somehow ServiceNow forgot to add the Related Lists concerned to the Catalog Item form (not only for upgraded instances, also out-of-the-box). With the Quebec release this has been solved, the Related List has been added.
Want to know more about Catalog data lookup definitions, see this article from @Ashley Snyder :
Service Catalog Data Lookup
Catalog data lookup rules on any table
The Catalog data lookup definition added with the Paris release is already a nice game changer within Service Catalog. Though now having data lookup rules available on any table, WOW! Gone is the need to always script data lookups through Catalog Client Scripting with (ideally) GlideAjax (and getXMLAnswer).
(If you still need to use Catalog Client Scripting with GlideAjax and getXMLAnswer, read about it in one of my previous articles: Client Side Scripting: Go for GlideAjax (with getXMLAnswer)!
So what is it actually about then, what is the WOW?
Catalog Data Lookup Definition
Let's start by adding a user reference variable and a location reference variable. Next up, adding a Catalog Data Lookup Definition.
Okay, so now you can select any table here. What does that offer us? After adding the Catalog Data Lookup Definitions record, two Related Lists get visible: Catalog Matcher Variable Definitions and Catalog Setter Variable Definitions. The titles already spoil what there about, though let's walkthrough.
Catalog Matcher Variable Definition
Catalog Setter Variable Definition
Result
After adding the Catalog Data Lookup Definition and the Catalog Matcher and Setter Variable Definitions, when changing the matcher Variable on your Catalog Item, the setter Variable on your Catalog Item will be automatically populated! No scripting involved, just basic configuration, WOW!
Small side note which I mentioned earlier. This does concern data lookups on the same table. So for more complex data lookups, retrieving data from other tables, having additional GlideRecord queries, etcetera: you would still need to use Catalog Client Script and GlideAjax (with getXMLAnswer).
---
https://www.servicenow.com/community/developer-articles/catalog-data-lookup-definition-on-any-table-eliminating-catalog/ta-p/2319138