From 06a92f734424e79b44979c0f2e6a728ea06a988a Mon Sep 17 00:00:00 2001 From: bkb68 Date: Tue, 1 Oct 2024 12:59:55 -0400 Subject: [PATCH 1/3] Update readme.md --- .../MRVS Interact With Parent Form/readme.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Catalog Client Script/MRVS Interact With Parent Form/readme.md b/Catalog Client Script/MRVS Interact With Parent Form/readme.md index 172a1958cc..cc01e74858 100644 --- a/Catalog Client Script/MRVS Interact With Parent Form/readme.md +++ b/Catalog Client Script/MRVS Interact With Parent Form/readme.md @@ -1,3 +1,4 @@ -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. +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. -The g_service_catalog object allows for accessing the "parent" GlideForm (g_form) object and its related functions +The g_service_catalog object allows for accessing the "parent" GlideForm (g_form) object for getValue only (for now?) +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). From bef28e6a6ff47303d2265d9ef877ab0c01cbaa9c Mon Sep 17 00:00:00 2001 From: bkb68 Date: Tue, 1 Oct 2024 13:05:43 -0400 Subject: [PATCH 2/3] Update Write to Parent Form.js --- .../Write to Parent Form.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Catalog Client Script/MRVS Interact With Parent Form/Write to Parent Form.js b/Catalog Client Script/MRVS Interact With Parent Form/Write to Parent Form.js index 84ccc57c67..0b4a4fcd02 100644 --- a/Catalog Client Script/MRVS Interact With Parent Form/Write to Parent Form.js +++ b/Catalog Client Script/MRVS Interact With Parent Form/Write to Parent Form.js @@ -1,7 +1,12 @@ -Use the g_service_catalog.parent object to interact with the parent form from within a MVRS script +//These methods can be used onLoad, onChange, or onSubmit in a script that Applies to the MRVS -//Retrieve a variable value from the parent form +//Retrieve a variable value from the parent form - works in native UI as well as Service Portal, etc. g_service_catalog.parent.getValue('variable_name'); -//Set a variable value on the parent form -g_service_catalog.parent.setValue('variable_name'); +//With this approach, you can set a variable value on the parent form - use similar code for other g_form methods like clearValue +//Service Portal method requires an additional Catalog Client Script onLoad that Applies to the Catalog Item +if (this) { //Service Portal method + this.cat_g_form.clearValue('variable_name'); + } else { //native UI method + parent.g_form.clearValue('variable_name'); + } From 6eea2b34c7a882953e6b3fe3762d39dd9b53a43f Mon Sep 17 00:00:00 2001 From: bkb68 Date: Tue, 1 Oct 2024 13:10:01 -0400 Subject: [PATCH 3/3] Create Portal onLoad.js --- .../MRVS Interact With Parent Form/Portal onLoad.js | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Catalog Client Script/MRVS Interact With Parent Form/Portal onLoad.js diff --git a/Catalog Client Script/MRVS Interact With Parent Form/Portal onLoad.js b/Catalog Client Script/MRVS Interact With Parent Form/Portal onLoad.js new file mode 100644 index 0000000000..6a34a6af1a --- /dev/null +++ b/Catalog Client Script/MRVS Interact With Parent Form/Portal onLoad.js @@ -0,0 +1,7 @@ +//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 +function onLoad() { + if (this) {//we only need to do this for Service Portal + //We need to make the g_form object for the parent item available from the MRVS window + this.cat_g_form = g_form; + } +}