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

Dynamic Rule Base for Order Guide

John Tomko
Tera Expert

We are building an order guide to onboard new users.  This group of users will be related to a Company record that contains a list field that dictates which catalog items should be used to set the rule base on the order guide (we want to limit what they can request and don't want to have to add a rule base entry for every possible catalog item).

Using MS Copilot I was able to build a script include and client script that is successfully retrieving a list of catalog item Sys IDs from the Company record and populating them into what will be a hidden comma-separated variable on the Order Guide.  However, all of the instructions I can find indicate I should use that to populate a list of catalog items on the Order Guide's "Rule Base Script".  This field doesn't exist on Order Guide or Rule Base.

3 REPLIES 3

SD_Chandan
Kilo Sage

Hi @John Tomko ,

Add rule base on condition of your variable and add Catalog item as per requirement


Thank you
Chandan

That is kind of a last resort solution but one I’ve considered.  The hope was that I wouldn’t have to build a rule base for every potential catalog item. 

John Tomko
Tera Expert

So... I got it to work, though my solution is very hack-y and not likely supported.

  1. Created an onChange client script on the Order Guide for the company variable (which contains a list field filled with the catalog items I want to use).  This puts the sys_ids in a comma-separated variable that I plan to hide.

  2. Hacked together this solution in the Order Guide script to get the value in that variable and loop through, using guide.add to add the values to the Order Guide (65529f0e1b636250923a1132b24bcbe5 is the sys_id of the variable containing the values I want to use to populate the Order Guide):

var getCart = new GlideRecord('sc_cart'); //preparing to query the sc_cart table
getCart.get(current.sys_id); //retrieving the current order guide record for this user
var elems = getCart.getElements().toString();
elems = elems.split("65529f0e1b636250923a1132b24bcbe5=")[1];
elems = elems.split("\n")[0];
var items = [];
items = elems.split(",");

for(var j = 0; j < items.length; j++){
	guide.add(items[j]);
}​