Skip to content

Commit 1983e7b

Browse files
authored
Mrvs reference qualifier from catalog item (#1126)
1 parent 6013cba commit 1983e7b

File tree

4 files changed

+42
-10
lines changed

4 files changed

+42
-10
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
function onLoad() {
2+
var mgr = g_service_catalog.parent.getValue('v_manager'); //if using this script onLoad of the MRVS
3+
//var mgr = newValue; // if using this script onChange of the Catalog Item variable
4+
var filterString = 'active=true^manager=' + mgr; //Reference qualifier following the 'javascript:'
5+
//alternate method for Service Portal only
6+
// if (window == null){ //Service Portal method
7+
// var setfilter = g_list.get('v_employee');
8+
// setfilter.setQuery(filterString);
9+
// } else { //native UI method
10+
var ga = new GlideAjax('refQualUtils'); //Client callable Script Include Name
11+
ga.addParam('sysparm_name', 'setSysProp'); //Function in Script Include
12+
ga.addParam('sysparm_sys_prop_name', 'sr.mrvs.ref_qual.emp'); //System Property Name used in MRVS variable Reference qualifier
13+
ga.addParam('sysparm_sys_prop_value', filterString);
14+
ga.getXML(getResponse);
15+
16+
function getResponse(response) { //to avoid Service Portal 'There is a JavaScript error in your browser console'
17+
var answer = response.responseXML.documentElement.getAttribute("answer");
18+
}
19+
//}
20+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
var refQualUtils = Class.create();
2+
refQualUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
3+
4+
setSysProp: function(){
5+
var propertyName = this.getParameter('sysparm_sys_prop_name');
6+
var propertyValue = this.getParameter('sysparm_sys_prop_value');
7+
var property = gs.getProperty(propertyName);
8+
gs.setProperty(propertyName, propertyValue);
9+
return;
10+
},
11+
12+
type: 'refQualUtils'
13+
});

Catalog Client Script/MRVS Reference Qualifier from Catalog Item Variable/mrvs_ref_qual.js

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
*** This solution uses g_list, so it works in Service Portal (and I assume ESC) only, not the native UI / Service Catalog interface ***<br>
2-
Developed in collaboration with Chris Perry
1+
On a reference variable in a multi-row variable set, sometimes you want the reference qualifier to include the value of a variable that is part of the Catalog Item, not within the MRVS.
32

3+
In this simplified example, I have a Manager (v_manager) reference variable (sys_user table) that belongs to the Catalog Item. In the MRVS, I have an Employee (v_employee) reference variable (sys_user table). I only want to be able to select user records that are active, and the Manager is the user I selected on the Catalog Item variable.
44

5-
On a reference variable in a multi-row variable set, sometimes you want the reference qualifier to include the value of a variable that is part of the Catalog Item, not within the MRVS
5+
1) Set the advanced reference qualifier on the MRVS variable to
6+
javascript: gs.getProperty("sr.mrvs.ref_qual.emp");
7+
using a System Property Name of your choice
68

7-
When using this script that applies to the Variable set, not the Catalog Item, leave the Reference qualifier field on the MRVS variable empty
9+
2) Use the included onLoad Catalog Client Script that applies to the Variable set, or you can also use this onChange of the Catalog Item variable in a script that applies to the Catalog Item.
810

9-
In this simplified example, I have a Manager (v_manager) reference variable (sys_user table) that belongs to the Catalog Item. In the MRVS, I have an Employee (v_employee) reference variable (sys_user table). I only want to be able to select user records that are active, and the Manager is the user I selected on the Catalog Item variable.
11+
3) Add the included Client callable Script Include for the Catalog Client Script to call via GlideAjax. This Script Include uses parameters for the System Property Name and Value, so it can be re-used in every instance of this solution.
12+
13+
This solution works in both the Native UI and Service Portal. The script contains an alternate Service Portal only approach in the commented if block that can be used in conjunction with the native UI approach in the else block. This alternate Service Portal solution was developed in collaboration with Chris Perry.

0 commit comments

Comments
 (0)