AnsweredAssumed Answered

Custom button in custom module

Question asked by michielvaningen on Aug 22, 2015
Latest reply on Aug 23, 2015 by hats
Hi everyone, I'm using SugarCRM Enterprise, Version 7.6.0.0 (Build 1552)
 

I'm trying to add a button to a record view in a custom module, the button has been added to:  \custom\modules\1234_Invoices\clients\base\views\record\record.php: (part)

$viewdefs[$module_name] =
    array(
        'base' =>
            array(
                'view' =>
                    array(
                        'record' =>
                            array(
                                'buttons' =>
                                    array(
                                        0 =>
                                            array (
                                                'type' => 'button',
                                                'name' => 'cancel_button',
                                                'label' => 'LBL_CANCEL_BUTTON_LABEL',
                                                'css_class' => 'btn-invisible btn-link',
                                                'showOn' => 'edit',
                                            ),
                                        1 =>
                                            array (
                                                'type' => 'rowaction',
                                                'event' => 'button:save_button:click',
                                                'name' => 'save_button',
                                                'label' => 'LBL_SAVE_BUTTON_LABEL',
                                                'css_class' => 'btn btn-primary',
                                                'showOn' => 'edit',
                                                'acl_action' => 'edit',
                                            ),

                                        3 =>
                                            array(
                                                'type' => 'button',
                                                'event' => 'button:do_some_task:click',
                                                'name' => 'do_some_task',
                                                'label' => 'Click me',
                                                'acl_action' => 'view',
                                            ),
                                    ),

The records.js in the same location looks like this:

({
    extendsFrom: 'RecordView',
    initialize: function (options) {
        this._super('initialize', [options]);

        this.context.on('button:do_some_task:click', this.do_some_task, this);

        console.log('GlobalView:: initialize');
    },
    render: function()
    {
        console.log('GlobalView:: render');
        this._super('render');
    },
    do_some_task: function() {
        this.model.set('invoice_ref', 'test');
        console.log('GlobalView:: click');
    }

});

I do see the console log calls appear in the console, but I'm not able to
get the button to work, it does show in the record view, but if I click it,
nothing happens, what am I doing wrong?

Thanks,
Michiel

Outcomes