Skip to content

Commit 7380984

Browse files
authored
Mrvs interact with parent form (#1083)
* Update readme.md * Update Write to Parent Form.js * Create Portal onLoad.js
1 parent 8248467 commit 7380984

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//Using this Catalog Client Script that Applies to the Catalog Item will enable g_form methods like setValue and clearValue which affect Catalog Item variables from a Catalog Client Script that applies to the multi-row variable set
2+
function onLoad() {
3+
if (this) {//we only need to do this for Service Portal
4+
//We need to make the g_form object for the parent item available from the MRVS window
5+
this.cat_g_form = g_form;
6+
}
7+
}
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
Use the g_service_catalog.parent object to interact with the parent form from within a MVRS script
1+
//These methods can be used onLoad, onChange, or onSubmit in a script that Applies to the MRVS
22

3-
//Retrieve a variable value from the parent form
3+
//Retrieve a variable value from the parent form - works in native UI as well as Service Portal, etc.
44
g_service_catalog.parent.getValue('variable_name');
55

6-
//Set a variable value on the parent form
7-
g_service_catalog.parent.setValue('variable_name');
6+
//With this approach, you can set a variable value on the parent form - use similar code for other g_form methods like clearValue
7+
//Service Portal method requires an additional Catalog Client Script onLoad that Applies to the Catalog Item
8+
if (this) { //Service Portal method
9+
this.cat_g_form.clearValue('variable_name');
10+
} else { //native UI method
11+
parent.g_form.clearValue('variable_name');
12+
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
Use this code snippet to interact with the parent form (i.e the main catalogue item) from within a catalog client script on a Multi-row variable set.
1+
Use this code snippet to interact with the parent form (i.e the main Cataloge Item) from within a Catalog Client Script that applies to a multi-row variable set.
22

3-
The g_service_catalog object allows for accessing the "parent" GlideForm (g_form) object and its related functions
3+
The g_service_catalog object allows for accessing the "parent" GlideForm (g_form) object for getValue only (for now?)
4+
To affect a variable in the main catalogue item using setValue, clearValue, etc. parent.g_form... is available in the native UI, and this.cat_g_form... can be used for Service Portal, etc if an additional Catalog Client Script is used, this one onLoad that Applies to the Catalog Item (not the MRVS).

0 commit comments

Comments
 (0)