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 Reply Children
  • Issue Solved : Able to get Alert Message on click on submit butto. 

    Casue Of Issue : Metadata not formatted properly.

    Thanks for the suggestions. Apprciated.

    .........................................................................................................................

    New Question : I have some APIs in Acconts/clients/base/api/mycustomAPI.php. On click of the button (which we have create above) , it should call that API. 

    Sugar CRM version used : 10.3 

    API  url :http://3.82.61.201/sugarcrm/rest/v10/Accounts/mycustomAPI/?id=62aace7c-8729-11eb-a0e4-0e1a95bf95b1

    My 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.api.call('update',app.api.buildURL('Accounts/' + this.model.get('id') + '/mycustomAPI') ,null {
    success:function(fdata)
    {
    app.alert.show('success', {
    level: 'error',
    messages: 'Activated.',
    autoClose: false
    });
    },
    error: function(error){
    app.alert.show('err', {
    level:'error',
    title: app.lang.getAppString('ERR_INTERNAL_ERR_MSG'),
    messages: err,
    autoClose: false
    });
    },
    });
    }
    })

    Please help me with the code here. !!!

  • Hello Gautam

    It looks like you are developing Sugar code - I'd suggest posting in the DevClub too so that much more developers than ones subscribed to this chapter could read your questions and share the ideas, helping you to enhance Sugar with code faster

    Good luck with overcoming coding challenges!

    Best Regards,
    Dmytro Chupylka

    integroscrm.com
    We make work in Sugar CRM system faster, more convenient and efficient