Creating Custom Script Task With predefined script

Hello,
I’ve been trying to create a custom BPMN script task with predefined scriptFormat and script.
I’m currently editing the custom elements example (https://github.com/bpmn-io/bpmn-js-example-custom-elements).

In CustomPalette.js I’ve been able to add the custom script task to the palette and add it to the canvas

 'custom-scripttask': {
        group: 'activity', 
        className: 'bpmn-icon-script-task',
        title: translate('Script task'), 
        action: {
          dragstart: createScriptTask('console.log("test");\nnext(null, "done");', 'Javascript'), 
          click: createScriptTask('console.log("test");\nnext(null, "done");', 'Javascript')
        }
      }

function createScriptTask(script, scriptFormat) {
      return function(event) {
        console.log(event);
        const shape = elementFactory.createShape({
          type: 'bpmn:ScriptTask'
        });

        create.start(event, shape);
      };
    }

but I’m not able to define scriptFormat and add the script tag as a child of the Script task.
How can I achieve this?

This example works for me: https://codesandbox.io/s/bpmn-js-custom-palette-3w792. It modifies the Palette to create a ScriptTask with predefined scriptFormat and script value.

1 Like

Thank you this solved my issue, is there anywhere where I can find all the properties of businessObject? I would like to add a custom element of every type to the palette with predefined values and properties.

You can check the properties of each element in the moddle descriptors:

1 Like