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