From 9ba35531b37646caca6175d99f53b5dfa99c053d Mon Sep 17 00:00:00 2001 From: Brad Bowman Date: Tue, 7 Oct 2025 08:13:27 -0400 Subject: [PATCH 1/9] 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/9] 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/9] 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/9] 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. From e6df91fed01ff2dd82cdcc5413c87c3438b614d3 Mon Sep 17 00:00:00 2001 From: Brad Bowman Date: Tue, 7 Oct 2025 08:53:39 -0400 Subject: [PATCH 5/9] Create Script Include moved from server component folder --- .../Script Include | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Client-Side Components/Catalog Client Script/MRVS dependent ref qual 1st row/Script Include diff --git a/Client-Side Components/Catalog Client Script/MRVS dependent ref qual 1st row/Script Include b/Client-Side Components/Catalog Client Script/MRVS dependent ref qual 1st row/Script Include new file mode 100644 index 0000000000..602bc20056 --- /dev/null +++ b/Client-Side Components/Catalog Client Script/MRVS dependent ref qual 1st row/Script Include @@ -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 1fcecf4a5ef2b66e7ad95c5a34be8345ca2c8095 Mon Sep 17 00:00:00 2001 From: Brad Bowman Date: Tue, 7 Oct 2025 08:57:29 -0400 Subject: [PATCH 6/9] Update README.md combined client script and script include folders --- .../MRVS dependent ref qual 1st row/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 index 861b2ac704..d700088dc9 100644 --- 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 @@ -1,6 +1,6 @@ -This Catalog Client Script is used with a Script Include and reference qualifier similar to +This Catalog Client Script and Script Include are used with a 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. +The 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. The Script Include will pass the department name to the reference qualifier. From b1e3cb063fae71ca0916c301c2f2a3261a707f8e Mon Sep 17 00:00:00 2001 From: Brad Bowman Date: Tue, 7 Oct 2025 08:59:48 -0400 Subject: [PATCH 7/9] Delete Server-Side Components/Script Includes/MRVS dependent ref qual 1st row directory combined folders --- .../MRVS dependent ref qual 1st row/README.md | 6 ------ .../set session data | 19 ------------------- 2 files changed, 25 deletions(-) delete mode 100644 Server-Side Components/Script Includes/MRVS dependent ref qual 1st row/README.md delete 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/README.md b/Server-Side Components/Script Includes/MRVS dependent ref qual 1st row/README.md deleted file mode 100644 index 4e0b870e54..0000000000 --- a/Server-Side Components/Script Includes/MRVS dependent ref qual 1st row/README.md +++ /dev/null @@ -1,6 +0,0 @@ -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. 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 deleted file mode 100644 index 602bc20056..0000000000 --- a/Server-Side Components/Script Includes/MRVS dependent ref qual 1st row/set session data +++ /dev/null @@ -1,19 +0,0 @@ -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 4c0b1f1c44b6bbf123200e70266db2bc0fd41fdc Mon Sep 17 00:00:00 2001 From: Brad Bowman Date: Tue, 7 Oct 2025 09:12:50 -0400 Subject: [PATCH 8/9] Rename Script Include to AccountUtils.js --- .../{Script Include => AccountUtils.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Client-Side Components/Catalog Client Script/MRVS dependent ref qual 1st row/{Script Include => AccountUtils.js} (100%) diff --git a/Client-Side Components/Catalog Client Script/MRVS dependent ref qual 1st row/Script Include b/Client-Side Components/Catalog Client Script/MRVS dependent ref qual 1st row/AccountUtils.js similarity index 100% rename from Client-Side Components/Catalog Client Script/MRVS dependent ref qual 1st row/Script Include rename to Client-Side Components/Catalog Client Script/MRVS dependent ref qual 1st row/AccountUtils.js From 0866c0b916665a5ec4c966bc56994f0255cc44fa Mon Sep 17 00:00:00 2001 From: Brad Bowman Date: Tue, 7 Oct 2025 09:13:25 -0400 Subject: [PATCH 9/9] Rename onLoad mrvs to onLoad.js --- .../MRVS dependent ref qual 1st row/{onLoad mrvs => onLoad.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Client-Side Components/Catalog Client Script/MRVS dependent ref qual 1st row/{onLoad mrvs => onLoad.js} (100%) 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.js similarity index 100% rename from Client-Side Components/Catalog Client Script/MRVS dependent ref qual 1st row/onLoad mrvs rename to Client-Side Components/Catalog Client Script/MRVS dependent ref qual 1st row/onLoad.js