Call handler error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Juantreses
    Junior Member
    • Aug 2025
    • 13

    #1

    Call handler error

    I've got the following handler:

    Code:
    define(['action-handler'], (Dep) => {
    return class extends Dep {
    async logMessageSent(data, e) {
    this.view.disableMenuItem('logMessageSent');
    Espo.Ajax.postRequest('lead/action/logMessageSent', {
    id: this.view.model.id
    })
    .then((response) => {
    this.view.model.fetch();
    this.view.reRender();
    Espo.Ui.success('Bericht gestuurd.');
    })
    .catch(() => {
    Espo.Ui.error('Bericht verstuurd kon niet worden gelogd.');
    })
    .finally(() => {
    this.view.enableMenuItem('logMessageSent');
    });
    }
    isLogMessageSentVisible() {
    return this.view.model.attributes.status === 'message_to_be_sent';
    }
    }
    });
    Lead config in buttons:
    Code:
    {
    "label": "Bericht Gestuurd",
    "name": "logMessageSent",
    "action": "logMessageSent",
    "style": "default",
    "acl": "edit",
    "aclScope": "Lead",
    "handler": "custom:handlers/log-message-sent-handler",
    "actionFunction": "logMessageSent",
    "checkVisibilityFunction": "isLogMessageSentVisible"
    }
    It is set up similarly to other handlers I have. Except for the fact the other handlers open a modal with a form sending an AJAX request from there. So this one is set up easier than the rest.

    However on click I get the following error:
    Code:
    Uncaught TypeError: Cannot read properties of undefined (reading 'call')
    at espo-main.js:655:27
    at Object._load (loader.js:702:21)
    at Object.require (loader.js:437:22)
    at Object.require (loader.js:1140:20)
    at Object.handleAction (espo-main.js:653:21)
    at click .action (espo-main.js:26563:20)
    at HTMLDivElement.dispatch (jquery.js:5136:27)
    at f.handle (jquery.js:4940:28)
    I would think something is wrong in my config but everything seems to be correct.
  • eymen-elkum
    Active Community Member
    • Nov 2014
    • 475

    #2
    This code will solve the problem.

    HTML Code:
    define('custom:handlers/log-message-sent-handler',['action-handler'], (Dep) => {
    return class extends Dep {
    async logMessageSent(data, e) {
    this.view.disableMenuItem('logMessageSent');
    Espo.Ajax.postRequest('lead/action/logMessageSent', {
    id: this.view.model.id
    })
    .then((response) => {
    this.view.model.fetch();
    this.view.reRender();
    Espo.Ui.success('Bericht gestuurd.');
    })
    .catch(() => {
    Espo.Ui.error('Bericht verstuurd kon niet worden gelogd.');
    })
    .finally(() => {
    this.view.enableMenuItem('logMessageSent');
    });
    }
    isLogMessageSentVisible() {
    return this.view.model.attributes.status === 'message_to_be_sent';
    }
    }
    });
    CEO of Eblasoft
    EspoCRM Expert since 2014
    Full Stack Web Developer since 2008
    Creator of Numerous Successful Extensions & Projects​

    Comment

    • Juantreses
      Junior Member
      • Aug 2025
      • 13

      #3
      Hi Eymen,

      Thanks for the help. This does indeed fix the issue but I do not understand why exactly. What is the difference between this and the other handlers that this needs to be included in the define? My other handlers do not have this included and work perfectly fine?

      Comment

      • seriessore
        Junior Member
        • Aug 2025
        • 2

        #4
        Originally posted by Juantreses
        Hi Eymen,

        Thanks for the help. This does indeed fix the issue but I do not understand why exactly. What is the difference between this and the other handlers that this needs basketball stars to be included in the define? My other handlers do not have this included and work perfectly fine?
        The difference is that your other handlers are likely bundled or referenced differently, so the module name gets resolved automatically. In this case, explicitly defining 'custom:handlers/log-message-sent-handler' ensures EspoCRM can properly load and link it.

        Comment

        Working...