The CreatorCon Call for Content is officially open! Get started here.

multi row variable set and functions from onLoad catalog client scripts

poyntzj
Kilo Sage

In my catalog Item I have a catalog client script that is configured as an onLoad (non isolated) and will load a function I can use throughout the catalog item on any item variables or any variables in the variable sets.  all pretty standard

I have added a MRVS to this catalog item but it cannot use the function from the catalog client script, complains it is not defined

Is this possible or do I need to write the routine into the MVRS itself ? (annoying as there could then be 2 sets of code to maintain)

The code is

function onLoad() {
}

updateIsError = function() {
  // do something
}

and the error in the MVRS is 

find_real_file.png

Just wonder if I am missing a trick here - such as a variable set attribute -  as the function is available to all of the other variable and variable sets in the item. I guess the modal maybe getting in the way, but why would its own client scripts work ?

 

 

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

can you share what exactly is your requirement here?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur

 

Thought it was pretty simple

in my catalog item, a catalog client script is loaded as an onLoad script and loads a function that can be called by any other Catalog Client script associated with this catalog item - either a catalog client script direct to the catalog item or a catalog client script from any of the linked variable sets.

All pretty standard

in the MRVS I want to do the same, but it cannot call the loaded function as it tells me it is undefined.  Clearly something with the MRVS

art_jones
Kilo Sage

Unfortunately not sure this is currently possible (reference an item's script from a MRVS).  I've found that there are challenges when trying to reference anything between a MRVS and it's parent item in scripts. Sometimes I end up with scripts on both depending on what I need to accomplish (e.g. need a reference qualifier on a MRVS variable that uses a value from a variable on the parent form -> script on parent sets a hidden variable on the MRVS, and script on the MVRS makes a Glide Ajax call).

Yeah, its what I have done in the past as I did not have time to worry and it was a single script, however this time this MRVS is using a few functions and just seems silly having to copy them into the MRVS and create its own functions

More for simplicity of code maintenance and removal of duplication of code

 

It's almost as if the MRVS have an inbound isolation setting