controller undefined does not exist

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • YNWA
    Junior Member
    • Nov 2024
    • 2

    controller undefined does not exist

    define('lead-split:views/lead/split-decision', ['action-handler'], (Dep) => {
    return class extends Dep {
    setup() {
    super.setup();
    console.log('Mass action for Leads initialized.');
    }
    launchUserSelect() {
    console.log('Launching user selection modal for Leads.');

    // Retrieve selected leads
    const selectedLeads = this.model.get('ids'); // Assumes `ids` holds selected lead IDs

    if (!selectedLeads || selectedLeads.length === 0) {
    Espo.Ui.notify('No leads selected. Please select leads first.', 'warning');
    return;
    }

    // Launch the user-selection modal
    this.createView('userSelectionModal', 'lead-split:views/modal/user-selection', {
    scope: 'User',
    selectedLeadIds: selectedLeads, // Pass selected leads to the modal
    onSubmit: (selectedUserIds) => {
    if (!selectedUserIds || selectedUserIds.length === 0) {
    Espo.Ui.notify('No users selected. Action canceled.', 'warning');
    return;
    }

    console.log('Selected Leads:', selectedLeads);
    console.log('Selected Users:', selectedUserIds);

    // Send selected leads and users to the handler !! path might be wrong doublecheck!!
    Espo.Ajax.postRequest('Espo/Modules/LeadSplit/Controllers/LeadController', {
    leadIds: selectedLeads,
    userIds: selectedUserIds
    }).then((response) => {
    Espo.Ui.notify(response.message, 'success');
    this.updateListView(); // Refresh list view after action
    }).catch((error) => {
    console.error('Error distributing leads:', error);
    Espo.Ui.notify('Failed to distribute leads.', 'error');
    });
    }
    }).then((modalView) => {
    modalView.render(); // Render the modal after it's created
    });
    }

    afterRender() {
    super.afterRender();
    // Bind the button click to the `doSomething` function
    this.$el.on('click', '.split-leads-button', () => {
    this.launchUserSelect();
    });
    }
    onRemove() {
    super.onRemove();
    // Clean up event listeners
    this.$el.off('click', '.split-leads-button');
    }
    };
    });
    ​handler

    {
    "massActionList": [
    "__APPEND__",
    "Assign Users"
    ],
    "checkAllResultMassActionList": [
    "__APPEND__",
    "Assign Users"
    ],
    "massActionDefs": {

    "handler": "lead-split:views/lead/record/split-decision",
    "initFunction": "setup",
    "actionFunction": "launchUserSelect"

    }
    }​

    WARNING: (404) Controller 'Undefined' does not exist. :: GET /undefined :: C:\xampp\htdocs\espocrm\application\Espo\Core\Api\ ControllerActionProcessor.php(189)

    this error happens after i click massAction button i created, is there something im missing ?
  • Kharg
    Senior Member
    • Jun 2021
    • 410

    #2
    Yes.

    this is your action handler:
    lead-split:views/lead/split-decision​

    this is the handler you are using for the mass action:
    lead-split:views/lead/record/split-decision​


    also,

    you have to use the correct url to send the post request
    instead of sending it to:
    Espo/Modules/LeadSplit/Controllers/LeadController​
    Last edited by Kharg; 11-25-2024, 02:46 PM.

    Comment

    Working...