Tired of having Business Process Errors? Try your own titles

By | April 17, 2024

It’s been there forever – you raise an error from the plugin, and you get Business Process Error popup in the UI. That’s all good except that not everyone likes that kind of popup title:

So how about making it a different title?

There is no supported way of doing this, but, well, lately I’ve been starting to think that, perhaps, “supported” or “not” is more a question of comparing pros and cons. If you can do something to make things look better without introducing huge risks, then it may be worth doing it. And, in order to change the title, you just need to add a MutationObserver – there is sample code below:

const config = { childList: true, subtree: true };
const callback = (mutationList, observer) => {
  for (const mutation of mutationList) {
    if (mutation.target && mutation.target.id.startsWith("dialogTitleContainer")) {
      var errorDialogTitle = document.querySelector("h1[data-id='dialogTitleText']");
      if(errorDialogTitle) errorDialogTitle.innerHTML = "My Own Error Title";
    } 
  }
};
const observer = new MutationObserver(callback);
observer.observe(document.body, config);

You might add it in the form onload. Or you might probably add it as a library for your custom ribbon button if you wanted this to work for a grid/subgrid.

And, of course, you’d need to accept the possibility of this stopping to work, but, given how straightforward that code is, the worst thing that might happen is that the original Business Process Error title would start showing up again, in which case you’d likely be able to fix it quickly by modifying the selector from document.querySelector(“h1[data-id=’dialogTitleText’]”); to whatever it might become in the future.

PS. You might choose to take it even further. In that code above, you might look at the message from the plugin. It would be yet another call to querySelector for a different element, you might possibly parse that message, and you might do whatever you want with the result (as in, might call a javascript function to update something on the form?) But you might, as well, hold off from taking it that far, simply because the more you customize in that area, the more you start relying on the unsupported customizations.

Leave a Reply

Your email address will not be published. Required fields are marked *