BPMN set checkBox default checked

Hello. Please help. How to set default checked = true in checkBox ?

    if (is(element, 'bpmn:SequenceFlow')) { 
      group.entries.push(entryFactory.checkbox(translate, {
        id: 'has_notification',
        label: i18n.t('bpmn.has_notification'),
        modelProperty: 'has_notification',
      })); 
    }

Hi,

you are referring to the bpmn-js-properties-panel.

A checkbox will show whatever value is returned from the get function. See for example the asyncContinuation checkbox:

var asyncBeforeEntry = entryFactory.checkbox(translate, {
    id: idPrefix + 'asyncBefore',
    label: labelPrefix + translate('Asynchronous Before'),
    modelProperty: 'asyncBefore',

    get: function(element, node) {
      var bo = getBusinessObject(element);
      return {
        asyncBefore: isAsyncBefore(bo)
      };
    },
[...]

So it depends on what you want to achieve now:

  • I would assume that you want the property (in your case has_notification) on the respective element to be true per default. In this case, you set it true when creating the element, the checkbox will then show as checked.
  • Alternatively you could just change the logic in the get function (see code snippet above), however note that even though you might then show the checkbox as checked, the actual data value true might not be persisted.