From 9ba35531b37646caca6175d99f53b5dfa99c053d Mon Sep 17 00:00:00 2001 From: Brad Bowman Date: Tue, 7 Oct 2025 08:13:27 -0400 Subject: [PATCH 1/4] Create onLoad mrvs Catalog Client Script to run onLoad of the MRVS, not the Catalog Item --- .../MRVS dependent ref qual 1st row/onLoad mrvs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Client-Side Components/Catalog Client Script/MRVS dependent ref qual 1st row/onLoad mrvs diff --git a/Client-Side Components/Catalog Client Script/MRVS dependent ref qual 1st row/onLoad mrvs b/Client-Side Components/Catalog Client Script/MRVS dependent ref qual 1st row/onLoad mrvs new file mode 100644 index 0000000000..6c041330e2 --- /dev/null +++ b/Client-Side Components/Catalog Client Script/MRVS dependent ref qual 1st row/onLoad mrvs @@ -0,0 +1,17 @@ +function onLoad() { + //applies to MRVS, not Catalog Item. This will pass the first selected account (if there is one) to a Script Include each time a MRVS row is added or edited + var mrvs = g_service_catalog.parent.getValue('my_mrvs'); //MRVS internal name + var acct = ''; + if (mrvs.length > 2) { //MRVS is not empty + var obj = JSON.parse(mrvs); + acct = obj[0].account_mrvs; + } + var ga = new GlideAjax('AccountUtils'); + ga.addParam('sysparm_name', 'setSessionData'); + ga.addParam('sysparm_account', acct); + ga.getXMLAnswer(getResponse); +} + +function getResponse(response) { + //do nothing +} From 02de94c1d01d196deee6ca0c85ec772520275186 Mon Sep 17 00:00:00 2001 From: Brad Bowman Date: Tue, 7 Oct 2025 08:17:16 -0400 Subject: [PATCH 2/4] Create set session data Script Include to work with reference qualifier and onLoad Catalog Client Script --- .../set session data | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Server-Side Components/Script Includes/MRVS dependent ref qual 1st row/set session data diff --git a/Server-Side Components/Script Includes/MRVS dependent ref qual 1st row/set session data b/Server-Side Components/Script Includes/MRVS dependent ref qual 1st row/set session data new file mode 100644 index 0000000000..602bc20056 --- /dev/null +++ b/Server-Side Components/Script Includes/MRVS dependent ref qual 1st row/set session data @@ -0,0 +1,19 @@ +var AccountUtils = Class.create(); +AccountUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, { + + //Populate the department name from the account in the session data for the reference qualifier to use: + + setSessionData: function() { + var acct = this.getParameter('sysparm_account'); + var dept = ''; + var acctGR = new GlideRecord('customer_account'); //reference table for Account variable + if (acctGR.get(acct)) { + dept = '^dept_name=' + acctGR.dept_name; //department field name on account table + } + + var session = gs.getSession().putClientData('selected_dept', dept); + return; + }, + + type: 'AccountUtils' +}); From 03c4700d7849ad2396230e0ad3f02d4d9ff71846 Mon Sep 17 00:00:00 2001 From: Brad Bowman Date: Tue, 7 Oct 2025 08:33:49 -0400 Subject: [PATCH 3/4] Create README.md explain usage, reason for Catalog Client Script --- .../MRVS dependent ref qual 1st row/README.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Client-Side Components/Catalog Client Script/MRVS dependent ref qual 1st row/README.md diff --git a/Client-Side Components/Catalog Client Script/MRVS dependent ref qual 1st row/README.md b/Client-Side Components/Catalog Client Script/MRVS dependent ref qual 1st row/README.md new file mode 100644 index 0000000000..861b2ac704 --- /dev/null +++ b/Client-Side Components/Catalog Client Script/MRVS dependent ref qual 1st row/README.md @@ -0,0 +1,6 @@ +This Catalog Client Script is used with a Script Include and reference qualifier similar to +javascript: 'disable=false' + session.getClientData('selected_dept'); + +The scenario is a MRVS with a reference variable to the customer account table. When an (active) account is selected in the first row, subsequent rows should only be able to select active accounts in the same department as the first account. + +This Catalog Client Script will pass the first selected account (if there is one) to a Script Include each time a MRVS row is added or edited. From 6b6adfa3155c9f6e2ee70aa198e2df8788875f58 Mon Sep 17 00:00:00 2001 From: Brad Bowman Date: Tue, 7 Oct 2025 08:36:12 -0400 Subject: [PATCH 4/4] Create README.md explain usage and reason for Script Include --- .../MRVS dependent ref qual 1st row/README.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Server-Side Components/Script Includes/MRVS dependent ref qual 1st row/README.md diff --git a/Server-Side Components/Script Includes/MRVS dependent ref qual 1st row/README.md b/Server-Side Components/Script Includes/MRVS dependent ref qual 1st row/README.md new file mode 100644 index 0000000000..4e0b870e54 --- /dev/null +++ b/Server-Side Components/Script Includes/MRVS dependent ref qual 1st row/README.md @@ -0,0 +1,6 @@ +This Script Include is used with a Catalog Client Script and reference qualifier similar to +javascript: 'disable=false' + session.getClientData('selected_dept'); + +The scenario is a MRVS with a reference variable to the customer account table. When an (active) account is selected in the first row, subsequent rows should only be able to select active accounts in the same department as the first account. + +This Script Include will populate the department name from the account in the session data for the reference qualifier to use.