Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -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'
});
Loading