Changing Cart Quantity based on Order Guide Variable Using a Business Rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2015 08:58 AM
Changing Cart Quantity based on Order Guide Variable Value Using a Business Rule
I couldn't find the answer to a scenario we came up with so I figured out a solution and thought I would share it for those looking to do something similar. Side note, I've only been working with ServiceNow for a few months so there may be a better or more elegant approach but we found this method to work nicely.
Scenario: You want to create an Order Guide that has one or more variables associated with it. From here, you want to create one or more rule bases to include items from your Service Catalog. However, based on the variables selected in the Order Guide, you want to adjust the quantity of a specific Catalog Item to a value greater than the default of "1". While the option exists for a user to change the quantity in the shopping cart themselves, it is a better user experience to pre-configure their cart if the Order Guide is for a bundle that is in itself pre-configured.
For example: You have a Desktop Computer Setup Bundle that could have either a (2) Monitor setup or a (4) monitor setup depending on the Department that the user works in.
- Service Catalog | Order Guide | New
- Configure the Order Guide (enter a name, select a catalog, select a category, description, etc)
- Create a variable on the Order Guide (in my scenario, I ask a Yes or No question as to whether the user works in a certain department, e.g. Investment Office User)
- Enable the Cascade Variable Option within the Order Guide
- Create a Rule Base to include an item from the Service Catalog. In my scenario, I am including a 22" Monitor.
- Save the Order Guide
- Edit the Service Catalog Item referenced in Step 5 to include the same variable from Step 3. Since I didn't want to show people this when they ordered a monitor directly, I created a new UI Policy to hide this variable always. This is not required but just the way I set it up.
- Create a new Business Rule
- Select Table "Item [sc_cart_item]"
- Select When "Before"
- Select "Update Checkbox"
- Select "Advanced"
- Filter it for "Item | Is | 22" Monitor"
- Use the following code under the Advanced Tab:
(function executeRule(current, previous /*null when async*/) {
var investmentUser = current.variables.investment_user;
if (investmentUser == 'no') {
current.quantity.setValue('2'); // here we set the quantity of Monitors to a value of 2 because thats the standard user setup
}
else {
current.quantity.setValue('4'); // here we set the quantity of Monitors to a value of 4 because thats what an Investment User gets
}
})(current, previous);
So when someone executes an order guide, the cart will either have 2 monitors of the same item or 4 monitors of the same item added based on which department they work in.
- Labels:
-
Service Catalog
- 3,402 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2019 12:41 PM
It does not appear that this works for ServicePortal; is that a correct statement?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2019 12:58 PM
Erik - did you ever get an validation that this does not work in Service Portal? We are experiencing the same issue on Kingston. Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2020 03:13 PM
Now that we are in Orlando, I don't see that the ability to change the quantity within the order guide has been enhanced.
Can someone please confirm?
If no, what business works to make that happen?