Service Catalog Calculate Total....not price total
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-08-2025 07:21 AM
Hi all. I'm building a catalog that lists resource types for provisioning IT services. Each resource type has a numerical value (provisioning units, PUnits)) and each provisioning action is based on a selected project size XS, S, M, L, XL where each project size has a limit of 6, 20, 40, 60, 80 PUnits...respectively. If the XS = 6 PUnits, how would I have the catalog form throw an error if a user selects a combination of items that equals more than 6? The same would apply for 20, 40, 60, and 80.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-08-2025 08:00 AM
You can do one of two things.
- Create onChange client scripts the runs on the variables that need to be totaled and then throw an error. You will then need to clear the values and/or have an onSubmit client script to prevent them from ordering it anyway.
- Just have an onSubmit client script that throws the error when they try to submit the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-08-2025 08:25 AM
Thanks Brian. Guess I'm off to ChatGPT to have it write a script for me. I'm not an experienced coder.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-08-2025 10:11 AM
What are all the variable names that need to be totaled?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-08-2025 09:30 AM - edited ā04-08-2025 09:37 AM
Hello @davidvetter
If you need something like below, then here are the steps:
A Catalog item (sc_cat_item) with below variables:
Four Catalog Client Scripts as shown below:
Catalog Total onChange Client Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
// Define project size limits
var projectSizeLimits = {
"XS": 6,
"S": 20,
"M": 40,
"L": 60,
"XL": 80
};
// Get selected project size and limit
var projectSize = g_form.getValue('project_size');
var limit = projectSizeLimits[projectSize];
if (!limit) return;
// Get latest values (after delay)
var devVal = parseInt(g_form.getValue('resource_dev')) || 0;
var testerVal = parseInt(g_form.getValue('resource_tester')) || 0;
var analystVal = parseInt(g_form.getValue('resource_analyst')) || 0;
var totalVal = devVal + testerVal + analystVal;
// Clear existing messages
g_form.hideAllFieldMsgs('project_size');
// Show appropriate message
if (totalVal > limit) {
g_form.showFieldMsg(
'project_size',
"Total PUnits (" + totalVal + ") exceed the limit for " + projectSize + " (" + limit + ").",
"error"
);
} else {
g_form.showFieldMsg(
'project_size',
"Total PUnits: " + totalVal + " ā within limit for " + projectSize + " (" + limit + ").",
"info"
);
}
}
Other three onChange Client scripts as follows:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
//Type appropriate comment here, and begin script below
g_form.setValue('project_size', '');
}
NOTE: The three onChange Client scripts upon changing the Developers, Testers and Analysts value need a click anywhere in the form to set Project Size to None so that it's choice can be selected again for validation.
Hope that helps!