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. 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 +} 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. 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' +});