Pass a List Collector Selection from One Catalog Item to Another in an Order Guide

1. Purpose

This document explains how to make a choice selected in a List Collector variable in Catalog Item 1 appear as a ticked CheckBox variable in Catalog Item 2, when both items are part of the same order guide.

2. Scenario

  • Order guide: Hiring.
  • Catalog Item 1 (Laptop Request) contains a List Collector named test_collector (options: Test 1, Test 2, Test 3).
  • Catalog Item 2 (Laptop Request) contains three CheckBox variables: test_1, test_2, test_3.
  • When the user picks a choice in Item 1, the matching checkbox must be ticked in Item

3. Why the standard approach does not work

  • Cascading variables needs variables with the same name at the order guide level. Here the variables live only inside the catalog items and have different names.
  • Each item opens on its own tab of the guide, so g_form on Item 1 cannot reach the variables of Item 2.

The solution is to save the selection on the server when it changes in Item 1, and to read it back when Item 2 loads.

4. Solution overview

  1. A client callable Script Include (SharedChoice) stores and returns the selection using the user’s session.
  2. An onChange Catalog Client Script on Item 1 saves the selected sys_ids.
  3. An onLoad Catalog Client Script on Item 2 reads the saved value and ticks the matching checkboxes.

5.How To Implement

Step 1:

  1. Open Service Catalog > Catalog Definitions > Maintain Items and open Item(Laptop Request)
  2. In the Variables related list, click New. Set Type to List Collector, Name to test_collector, and set the List table on the Type Specifications tab.
  3. Open Item 2 and add three CheckBox variables named test_1, test_2 and test_3.

Step 2: Add the items to the order guide

  1. Go to Service Catalog > Catalog Definitions > Order Guides and open the Hiring guide.
  2. Add Item 1 and Item 2 using the Rule base tab (or the Included Items list if your version shows it). Give Item 1 a lower order than Item 2.
  3. Click Try It and confirm both items appear in the right order.

Step 3: Create the Script Include

  1. Go to System Definition > Script Includes > New.
  2. Set Name to SharedChoice, check Client callable and Active.
  3. Paste the script below and click Submit.

 

Step 4: Create the Catalog Client Script on Item 1

  1. Open Item 1 and go to the Catalog Client Scripts tab, then click New.
  2. Set Type to onChange and Variable name to test_collector.
  3. Check Active and Applies on Catalog Item view, and set UI Type to All.
  4. Paste the script below and click Submit.

Step 5: Create the Catalog Client Script on Item 2

  1. Open Item 2 (Laptop Request) and go to the Catalog Client Scripts tab, then click New.
  2. Set Type to onLoad. Check Active and Applies on Catalog Item view, and set UI Type to All.
  3. Paste the script below, replace the placeholders with the sys_ids from Step 5, and click Submit.

7. Testing

  1. Hard-refresh the browser (Ctrl+Shift+R).
  2. Open the Hiring order guide with Try It.
  3. In Item 1, move Test 1 to the Selected side.
  4. Switch to Item 2. Within about 2 seconds test_1 should be ticked and the other boxes unticked.
  5. Go back to Item 1 and add or remove choices. Item 2 should follow the changes.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top