Skip to content

Commit 8074943

Browse files
authored
Create readme.md
1 parent a81a30b commit 8074943

File tree

1 file changed

+32
-0
lines changed
  • Server-Side Components/Business Rules/Find MRVS Total

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Server-Side MRVS Total Calculator
2+
This ServiceNow Business Rule automatically calculates the sum of a numeric field from all rows within a Multi-Row Variable Set (MRVS) after a catalog item has been submitted.
3+
It populates a separate variable with the calculated total, making the value easily accessible for flows, reports, and integrations without needing to parse the MRVS JSON every time. This script is designed to run on the back-end, ensuring the total is accurate and persistent.
4+
5+
## How to Implement
6+
Follow these steps to configure the Business Rule in your instance.
7+
8+
### 1. Prerequisites
9+
Before creating the rule, make sure you have the following variables on your Catalog Item:
10+
11+
- A Multi-Row Variable Set (e.g., named item_details).
12+
- A variable inside the MRVS that will contain a number (e.g., named quoted_price).
13+
- A single variable outside the MRVS to store the final sum (e.g., a Single Line Text variable named total_estimate).
14+
15+
### 2. Business Rule Configuration
16+
Create a new Business Rule with the following settings:
17+
- Name: A descriptive name like Calculate MRVS Total on RITM.
18+
- Table: Requested Item [sc_req_item].
19+
- Advanced: Check this box to reveal the script field.
20+
- When to run:
21+
- When: Before
22+
- Insert: true
23+
- Update: true
24+
25+
Copy and paste the script from `mrvs_total_sum.js` into the Script field within the Advanced tab of your Business Rule.
26+
27+
Before saving, you must update the three configuration variables at the top of the script to match your specific setup.
28+
You will need to set the following:
29+
- `VARIABLE_NAME_TO_POPULATE_WITH_SUM` to the internal name of your total variable
30+
- `MRVS_INTERNAL_NAME` to the internal name of your Multi-Row Variable Set
31+
- `MRVS_VARIABLE_NAME_TO_SUM` to the internal name of the numeric variable inside the MRVS that you want to sum.
32+

0 commit comments

Comments
 (0)