I have deployed a javascript file into the Camunda database. The name of the file is testJS.js. The content of the file is
function testJS(){
println(“test JS script”);
}
I have deployed a BPMN process as well with a script task.
Is it possible to call the testJS function from the BPMN script task?
If yes pls help how can I do it?
Have a look at the documentation on script sources. You can reference a script contained in a deployment by using the camunda:resource attribute, e.g. camunda:resource="deployment://org/camunda/bpm/task.groovy".
Thank you the info. The linked page was known for me that was the reason
why I would like to reuse an existing script but I don’t know how…
So I have created a JS script such as:
function testJS(testInput){
println(testInput);
return(testInput);
}
I have deployed with the built-in Camunda rest API. The name is js.
I have created a new bpmn process and in a script task I would like to run
my script. Set a workflow variable for example.
The JS deployment is success but I don’t know how can I set the variable. I
have no information about the deployment://path because it was deployed
into the database directly.
I have checked on Cockpit and the js was deployed.
I have tried to use as external script but I don’t know how can I assign
the deployed js and the BPMN file. If I would like to use an internal
script I have no idea how can I use in
the execution.setVariable(“wf_var”,???) statement.
When you reference a script via deployment://path, the process engine resolves it from the deployment that contains the process. That means, you must deploy the script along with the process.
Now if you want to reuse one script across many processes and process applications, I suggest the following:
Build a Java library that contains the scripts on the classpath
Add that library as a dependency to your process applications and include it in their deployments
Reference the script via camunda:resource="classpath://path/to/script.js"
Here we have the same problem.
It is absolutely despicable idea to create a chain of JAR to be referenced in a master process.
We 'd like to know if you found a workaround to this problem.
@thorben is possible that the resriction about SHARED JS is because the cache of the BPMN executor over the js engine?
Do you have plan to improve this?