How to hook into onload event for a workspace

In hooks.py I have an app wide link to custom js

app_include_js = "/assets/custom/js/custom.js"

And in custom.js I have code which triggers when the ‘Account’ form is loaded:

frappe.ui.form.on('Account', {
  onload: function(frm) {
      frappe.show_alert({
          message: "Account form is loaded!",
          indicator: 'green'
      }, 5);
  }
});

so far so good. This all works. HOWEVER when I use the same technique to try to hook in to the load event of a workspace it doesn’t fire. So this:

frappe.ui.form.on('CustomWorkspace', {
  onload: function(frm) {
      frappe.show_alert({
          message: "Workspace form is loaded!",
          indicator: 'green'
      }, 5);
  }
});

doesn’t fire when the workspace is displayed

Is it possible to hook into a workspace page in the same way? If so how is this done?

1 Like

Thank you. And good point in that thread that use case for customising a workspace may be limited, considering how easy it is to create your own workspace.