Hi guys ,
I want to define a function that I can create from it an instance in every script task and use its methods,I dont want to define it in every script task (javascript format)
Example :
function myFunction(a,b)={
return a+b;
}
Is it possible to add a class to Nashorn Script API of Activiti to add this ?
I am by no mean a Java expert so please take me slowly
Something Like this :
import java.util.*;import javax.script.*;public class TestBindings { public static void main(String args[]) throws Exception { String script = "function myFunction(a,b) {return a+b;}"; ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript"); CompiledScript cscript = compilingEngine.compile(script); Bindings bindings = engine.getBindings(ScriptContext.ENGINE_SCOPE); cscript.eval(bindings); Invocable invocable = (Invocable) cscript.getEngine(); invocable.invokeFunction("myFunction"); }}
How to do this and where to place the class file and how to call the function inside the script task ?
Cheers
Chemss
Solved! Go to Solution.
I am sorry that I have not tried it.
Cannot you use load function?
(ex) load("http://example.com/script.js")
I am sorry that I have not tried it.
Cannot you use load function?
(ex) load("http://example.com/script.js")
That did the job ! and in an easy way , THANK YOU !
Ask for and offer help to other Alfresco Process Services and Activiti Users and members of the Alfresco team.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.