Not able to get alert message on click of custom created button

1. I have created custom button called "SUBMIT" on module. (Working Fine)

2. I was trying to implement simple alert message on click of that button.

Process Followed:

https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_10.3/Cookbook/Adding_Buttons_to_the_Record_View/#Adding_Buttons_without_Overriding_View_Controllers

 Extend and override the record view controller:

./custom/modules/Accounts/clients/base/views/record/record.js

Code:

({

extendsFrom: 'RecordView',

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

//add listener for custom button
this.context.on('button:submit_button:click', this.submit_button, this);
},

submit_button: function() {

app.alert.show('submit-ok', {
level: 'success',
messages: 'Submitting Your Order .....',
autoClose: true
});

}
})

Please help with me with the correct  approach .

Parents
  • If you go back to the exact link you shared you will see that they are not using the record view at all, rather they are creating a new field type based on the "button".

    However, if you are wanting to modify the view controller, as you seem to be doing, you should follow the steps at the top of that page:

    https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_10.3/Cookbook/Adding_Buttons_to_the_Record_View/#Steps_To_Complete

    I am not seeing anything wrong with your code. I would check file permissions, and make sure you execute a Repair from your Admin menu. (controller changes require a Repair to take effect) Sorry, these things may seem obvious but I don't know how much you have worked with Sugar.

    Also double check your record.php to make sure the action is specified correctly, it should look something like:

    array(
        'type' => 'rowaction',
        'event' => 'button:submit_button:click',
        'name' => 'submit_button',
        'label' => 'LBL_SUBMIT_BUTTON',
        'acl_action' => 'view',
    ),

    The acl action may need to be different depending on the type of permissions you want to set for this button. But if anyone who can see the record should be able to click the button, then "view" is fine.

    Hope this gives you some ideas,

    FrancescaS

  • Followed below link:

    https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_10.3/Cookbook/Adding_Buttons_to_the_Record_View/#Steps_To_Complete

    1. Created Button .

    2.Defined label for button.

    3.Added custom button to record.php

    2 =>
    array (
    'type' => 'rowaction',
    'events' => 'button:submit_button:click',
    'name' => 'submit_button',
    'label' => 'LBL_SUBMIT_BUTTON_LABEL',
    'css_class' => 'btn btn-primary',
    'showOn' => 'edit',
    'acl_action' => 'edit',
    ),

    4..Create file called record.js at ./custom/modules/Orders/clients/base/views/record/record.js

    [record.js was not present initially so that's why I created]

    ({

    extendsFrom: 'RecordView',

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

    //add listener for custom button
    this.context.on('button:submit_button:click', this.submit_button, this);
    },

    submit_button: function() {

    app.alert.show('submit-ok', {
    level: 'success',
    messages: 'Submitting Your Order .....',
    autoClose: true
    });

    }
    })

    5. Check the permission of files (Correct) 

    6.Repair and Rebuild from Studio/Admin

    Result : No alert message on click of button

    Please check and suggest if I have missed something 

     

Reply
  • Followed below link:

    https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_10.3/Cookbook/Adding_Buttons_to_the_Record_View/#Steps_To_Complete

    1. Created Button .

    2.Defined label for button.

    3.Added custom button to record.php

    2 =>
    array (
    'type' => 'rowaction',
    'events' => 'button:submit_button:click',
    'name' => 'submit_button',
    'label' => 'LBL_SUBMIT_BUTTON_LABEL',
    'css_class' => 'btn btn-primary',
    'showOn' => 'edit',
    'acl_action' => 'edit',
    ),

    4..Create file called record.js at ./custom/modules/Orders/clients/base/views/record/record.js

    [record.js was not present initially so that's why I created]

    ({

    extendsFrom: 'RecordView',

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

    //add listener for custom button
    this.context.on('button:submit_button:click', this.submit_button, this);
    },

    submit_button: function() {

    app.alert.show('submit-ok', {
    level: 'success',
    messages: 'Submitting Your Order .....',
    autoClose: true
    });

    }
    })

    5. Check the permission of files (Correct) 

    6.Repair and Rebuild from Studio/Admin

    Result : No alert message on click of button

    Please check and suggest if I have missed something 

     

Children