File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
Client-Side Components/Catalog Client Script/Normalise and Reset a MRVS based on Variable Changes Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ # MRVS - Normalise and Reset Rows on Change
2+
3+ ## What this solves
4+ When a controlling variable changes (for example, Environment), existing MRVS rows may no longer be valid. This client script:
5+ - Clears or normalises specific MRVS columns
6+ - Deduplicates rows
7+ - Optionally sorts rows for a cleaner UX
8+ - Works entirely client-side using MRVS JSON
9+
10+ ## Where to use
11+ Catalog Item → OnChange client script on your controlling variable.
12+
13+ ## How it works
14+ - Reads the MRVS value as JSON via ` g_form.getValue('my_mrvs') `
15+ - Applies transforms (clear columns, unique by key, sort)
16+ - Writes back the JSON with ` g_form.setValue('my_mrvs', JSON.stringify(rows)) `
17+
18+ ## Setup
19+ 1 . Replace ` CONTROLLING_VARIABLE ` with your variable name.
20+ 2 . Replace ` MY_MRVS ` with your MRVS variable name.
21+ 3 . Adjust ` COLUMNS_TO_CLEAR ` , ` UNIQUE_KEY ` , and ` SORT_BY ` as needed.
22+
23+ ## Notes
24+ - To clear the MRVS entirely, set ` rows = [] ` before ` setValue ` .
25+ - Works with Catalog Client Scripts; no server call required.
26+
27+ ## References
28+ - GlideForm API (client): ` getValue ` , ` setValue ` , ` clearValue `
29+ https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/GlideForm/concept/c_GlideFormAPI.html
30+ - Working with MRVS values on the client (community examples)
31+ https://www.servicenow.com/community/developer-articles/accessing-multi-row-variable-set-value-outside-the-multi-row/ta-p/2308876
You can’t perform that action at this time.
0 commit comments