External Scripts Vs Java Delegates, best practice

Hi Camunda users,

I apologize in advance for the naivety of this post but I’m trying to find the best option to implement some simple code snippets, for the momemt I use Java Delegates for this purpose but I see that it’s also possible to use external scripts.

My question is quite simple, what reasons should guide the use of either external scripts or java delegates?

Thanks in Advance, Chris

Hi Chris,
Have a look at this guide in our best practices which provides some information regarding delegates versus scripting versus other approaches. Either approach is acceptable. For really simple stuff you can use inline scripting though I find for more complex scripting I prefer to use a ‘real’ IDE to compose the script and then ‘point’ to it from a script task. The advantage of using this approach, as well as using delegates, is that you don’t create a new version of a process if you make a change in the code. If you change the code in an inline script a new version of the process is created. In this example a groovy script needs to be included in the deployment of this application:
image

Joe

1 Like

Hi @Beagler,

Thanks for this clear answer, external scripts sound appealing indeed. I still have a question on the path that should be added, in Ressource, can it be something like:
deployment://home/chris/external_scripts/test.js ?
or external scripts should lie where my bpms are?

Thanks

You’re welcome! If you used one of the Camunda archetypes to create a project in your IDE you can place the script in the src/main/resources folder and refer to it just as test.js in your process. If you’re not using a project in an IDE you can use deployment://test.js and make sure to deploy it along with your .bpmn file using REST.

Joe

Perfect @Beagler! Thanks for your concern!