logo

NJP

Service Catalog - Using catalog client scripts on multi-row variable set to populate a custom table as and when user makes an entry to multi-row variable set

Import · Jan 25, 2021 · article

I am new to ServiceNOW community and here is my first article related to service catalog. Did not find an exact article on this topic so thought to write one up. Please share your feedback. Thanks!

Recently had a requirement on service catalog where user wanted to submit a single order to perform some operation in bulk on the specified assets.

User wanted to submit only one order but with multiple asset where some information is going to be unique across assets - hence we then have to deal with order level information that is going to common across assets under that order and asset level information that is going to be unique across all assets under that order.

The obvious choice for this was to introduce a 'multi-row' variable set that would capture this unique asset information in tabular format which could further be utilized for processing.

However, the solution i thought of needs a table to be populated in backend separately so that the records from the table can be utilized for further processing, without having to rely on question_answer/sc_item_option/sc_item_option_mtom tables and complex code to identify the questions and answers.

Hence, thought of writing a catalog client script to achieve this solution.

Below are the steps to achieve the solution -

  1. Create a multirow variable set with 2 fields - field x and field y.
  2. Add this variable set to any existing catalogue item in your PDI.
  3. Create a custom table with a couple of more columns (for further processing - optional if you dont need to) apart from field x and field y that will be captured from the multi-row variable set. Ensure that you have correctly selected the data types for field x and field y and the data types for these two fields matches with the data type of field x and field y of variable set.
  4. Create a catalogue client script
  5. Select 'Applies to' = 'A variable set'
  6. Select 'Type' = 'On Submit'
  7. Select 'Variable Set' =
  8. Write a piece of code in 'script' section as follows

image5. Save the catalogue client script.

6. Testing - Navigate to the service catalogue to which you added this multi-row variable set in step 2. Order it and start filling the multi-row variable set. On each click of 'Add' button on the popup, a table record will get created in the target table.

View original source

https://www.servicenow.com/community/itsm-articles/service-catalog-using-catalog-client-scripts-on-multi-row/ta-p/2306392