Import Modules Using a Global Functions Resource Path

While a JavaScript resource defined within a Visual Builder application can be imported into a container using existing conventions, it is often the case that an extension may want to share it for reuse by downstream extensions.

A downstream extension that extends from an upstream extension can also define its own global functions. Global functions can be defined at each extension level.

For example, a top level extension might have a set of JS modules that are used by layout business rules associated to layout artifacts. Rather than copy the code for the utility resource JavaScript in every downstream extension that requires the same logic, using the 'global functions' feature, an extension can define the resource and declare the rules for its usage in a functions.json metadata, . This allows a dependent downstream extension to import the JS module and use it with minimal effort.

As stated, global functions for use within the extension (and its App UIs), or across extensions, must first be declared in a functions.json metadata, along with level of access afforded to downstream extensions to the methods the JS module provides.

Note:

The term 'global function' refers to its usage as a globally available module, and must not be confused with a context, such as $global.