Hi Jared,
It depends on where you are in the process, but the context that is passed into the various function call backs typically serves to provide the the same functionality as the normal implicit service class. That said, the service variable only provides access to things you can do without it so it is sort of unnecessary and only there for convenience.
Here is how to do that on your own.
var ScriptCache = Java.type("com.ibm.tivoli.maximo.script.ScriptCache");
var ScriptDriverFactory = Java.type("com.ibm.tivoli.maximo.script.ScriptDriverFactory");
var result = invokeScript("YOUR_SCRIPT_NAME_HERE");
function invokeScript(scriptName) {
var scriptInfo = ScriptCache.getInstance().getScriptInfo(scriptName);
if (scriptInfo) {
var context = new HashMap();
ScriptDriverFactory.getInstance().getScriptDriver(scriptName).runScript(scriptName, context);
return context;
} else {
return null;
}
}
or
from com.ibm.tivoli.maximo.script import ScriptCache, ScriptDriverFactory
def invokeScript(scriptName):
scriptInfo = ScriptCache.getInstance().getScriptInfo(scriptName)
if (scriptInfo):
var context = new HashMap()
ScriptDriverFactory.getInstance().getScriptDriver(scriptName).runScript(scriptName, context)
return context
else:
return null
result = invokeScript("YOUR_SCRIPT_NAME_HERE")
As a fun addition, if you use JavaScript you can inline one script into another like so:
// Import the ScriptCache Java class.
ScriptCache = Java.type('com.ibm.tivoli.maximo.script.ScriptCache');
// Load the Excel library inline with the current script.
load({ script: ScriptCache.getInstance().getScriptInfo("YOUR_SCRIPT_NAME_HERE").getScriptSource(), name: "YOUR_SCRIPT_NAME_HERE" });