How to call external JS script?

Dear forum,

I have been searching the forum and could not find any information in this regard. Is it possible for a Task defined in the modeller interface to call an external JS/NodeJS script ? As I see now it is possible to define only an inline script when setting the execution listener/input parameters/output parameters to type Script β†’ Script Format JavaScript. But we would like for the activity to execute an external script.

Is there any possible way of doing this (without too much coding or a reasonable amount of coding) ?

Thank you

The Camunda BPMN extensions offers something like that via the resource propery.

<camunda:script scriptFormat="javascript" resource="foo" />

Cf. camunda-bpmn-moddle/camunda.json at master Β· camunda/camunda-bpmn-moddle Β· GitHub

image

Hi @alecxs86,

maybe it’s the external service task you are looking for: External Tasks | docs.camunda.org.

With @Niklas_Kiefer approach, the java script is executed in the process engine with the Nashorn Javascript implementation.

With external service task, you can use a NodeJs client like this: GitHub - camunda/camunda-external-task-client-js: Implement your BPMN Service Task in NodeJS. to invoke your business logic in JavaScript.

Hope this helps, Ingo

1 Like

Thank you for the reply. @Ingo_Richtsmeier

However your solution assumes the external NodeJS client calls the process. I am looking for the other way around. I would like for the process instance to call (execute) a script. Can you confirm such a behaviour is possible ?

Thank you

Hi @alecxs86,

This is possible. Have a look at the docs about possible options: Scripting | docs.camunda.org

Questions regarding the Camunda Platform and process execution are usually handled in this forum: https://forum.camunda.org

Hope this helps, Ingo