How to create a decision table in the DRD view programmatically [dmn js]

Hello team,

I am looking to create a new blank decision table in the DRD programmatically. My first attempt was to use createShape with the drd provider active. Something like below:

const createShape = React.useCallback(() => {
    if(editorRef.current) {
      if (typeof editorRef.current.getActiveViewer().get === 'function') {
        let views = editorRef.current.getViews();
        let modeling = editorRef.current.getActiveViewer().get('modeling');;

        let canvas = editorRef.current.getActiveViewer().get('canvas');;

        let rootElement = canvas.getRootElement();;

        let drdFactory = editorRef.current.getActiveViewer().get('drdFactory');;

        let elementFactory = editorRef.current.getActiveViewer().get('elementFactory');;

        let businessObject = drdFactory.create('dmn:Decision', {
          name: 'Season'
        let decision = elementFactory.createShape({
          type: 'dmn:Decision',
          businessObject: businessObject

        modeling.createShape(decision, { x: 100, y: 100 }, rootElement);'Shape created?');
      } else {'dmnEditor.get is not a function...');
    } else {'dmnEditor has not been initialized...');
  }, [editorRef]);

CreateShape is linked to a button on our webpage. This function created the decision node with “Season” as text. However, there was no decision table associated to it. What would the next steps be? And any recommendations on how to improve the above code is appreciated. Thanks!


The decision table can be added to a decision via decisionLogic property. Check out how it’s done at

Got it! Thank you very much. I am able to create decisionTable and literalExpression programmatically now.

For others future reference:

      let drdReplace = editorRef.current.getActiveViewer().get('drdReplace');
      let decisionNode = modeling.createShape(decision, { x: 200, y: 200 }, rootElement);
      let newElementData = {type: 'dmn:Decision', table: true, expression: false};
      let newDecisionNode = drdReplace.replaceElement(decisionNode, newElementData);
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.