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');
console.info(modeling);
let canvas = editorRef.current.getActiveViewer().get('canvas');
console.info(canvas);
let rootElement = canvas.getRootElement();
console.info(root);
let drdFactory = editorRef.current.getActiveViewer().get('drdFactory');
console.info(drdFactory);
let elementFactory = editorRef.current.getActiveViewer().get('elementFactory');
console.info(elementFactory);
let businessObject = drdFactory.create('dmn:Decision', {
name: 'Season'
});
let decision = elementFactory.createShape({
type: 'dmn:Decision',
businessObject: businessObject
});
console.info(decision);
console.info(decision['decisionLogic']);
modeling.createShape(decision, { x: 100, y: 100 }, rootElement);
console.info('Shape created?');
} else {
console.info('dmnEditor.get is not a function...');
}
} else {
console.info('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!