Skip to content

core.customizeInstances

Extend a definition instance viewer capabilities by implementing a range of customizations, such as controlling the instance's display, determining field visibility, adjusting box sizes, and more.

Usage:

javascript
core.customizeInstances("<definition-name>", function (instance, presenter) {
  ...
})

Arguments:

ArgumentDescriptionRequired
definition-nameRefers to the name of the specific definition to which you want to apply the customization.YES
functionCallback function responsible to implement the new functionalityYES

Function arguments:
ArgumentDescription
instanceThe instance model.
presenterThe instance presenter

Examples:

The code snippet in this example introduces a new button when editing a Ticket's instance. When clicked, it will automatically change the value of the 'State' field to 'Done' and save the instance.

javascript
cob.custom.customize.push(function (core, utils, ui) {
    const DEFINITION = "Tickets";
  
    core.customizeInstances(DEFINITION, function(instance, presenter) {
      if (!instance.isNew()) {
        const closeBtn = "<button class='js-close-btn btn btn-small btn-primary' style='margin-top: 20px;'><i class='icon-ok mr-1'></i><span>Close</span></button>";
        document.querySelector(".js-sidenav-btn-container").insertAdjacentHTML("beforeend", closeBtn);
        document.querySelector(".js-close-btn").addEventListener("click", () => {
          presenter.findFieldPs((fp) => fp.field.fieldDefinition.name === "State")[0].setValue("Done");
  
          presenter.saveInstance(() => {
            core.navigateBack();
          });
        });
      }
    });
});

done-btn