Reference Global Functions in an Expression
For the layout that defines the above modules, the following expressions can be used to call the methods exposed by a particular global functions module:
$layout.modules.commonUtils.titleCase()
$layout.modules.dateLocalUtils.dateToIsoString()
Where titleCase
and dateToIsoString
are the function names defined in functions.json
in the extension.
Note:
$modules
is the shortened form for use in the current container.
Note:
Any container that imports modules can expect$modules
to be available (for example, $page.modules
, $fragment. modules
).
An action chain JavaScript can provide $modules
as part of the context:
class MyChain extends ActionChain {
async run(context, params) {
context.$layout.modules.dateUtils.today();
const result = context.$application.modules.appUtils.update(); // can also call modules in parent scopes
await Actions.assignVariable(context,
{
variable: '$layout.variables.someValue',
value: result / 2,
});
}
}