Have you looked into dojo's lang.setObject (to create variables / functions) from one place / script adapter and then use lang.getObject to read them back from another?
I use this technique to externalize common functions and variables within a solution that can then be shared across multiple pages.
If you are talking about sharing variables across multiple script adapters in the same page then there is an alternative approach where you send all events through the same script adapter
Here's a code snippet showing use of getObject() and combining all of your into a single script adapter:
// connect all incoming events to this single script adapter
try {
require(["dojo/_base/lang"], function(lang){
var self = this;
// check the event name to see which bit of code needs to run
if (payload.eventName === "icm.FieldUpdated") {
// call a global function that you previously added to the DOM. you can even reference variables/constants as parameters
lang.getObject("my.namespace.functions.CaseFieldUpdated")(self,payload,lang.getObject("my.namespace.functions.CONSTANTS.MODELSCOPE.CASE"));
// or you can save a variable into the current object using self
self.myVariable = "Hello World";
}
// check the event name to see which bit of code needs to run
else if (payload.eventName === "icm.custom.UpdateAddressContact") {
// call another global function
lang.getObject("my.namespace.functions.UpdateAddress")(self,payload);
// and reference the value in myVariable
if(self.hasOwnProperty('myVariable')){
alert (self.myVariable);
}
}
});
}
catch (Error) {
alert ("Source Module: " + self.name + "\r\n\r\n"+Error.name+" - "+Error.description+"\r\n"+Error.message);
}
------------------------------
Dave Ward
------------------------------
Original Message:
Sent: Wed July 12, 2023 12:49 PM
From: Martin Iturbide
Subject: How to create "Environment Variables" on IBM Case Manager 5.3.3 ?
Hi
Can someone help me with some information or documentation on how to create "Environment Variables" on IBM Case Manager 5.3.3 ?
I need to create variables that can be stored once and be called from the javascript inside a "Script Adapter".
Thanks in advance.
------------------------------
Martin Iturbide
Consultant
Next Step C.A.
Quito
------------------------------