AnsweredAssumed Answered

Convert Lead - convert-main.js -  handleSave - app.alert.show

Question asked by swaldinger on Jan 29, 2019
Latest reply on Jan 30, 2019 by swaldinger

Hi all,

 

I want perform some checks before converting a lead to contact.

In some cases I want to confirm the user to save before "Save and convert" gets executed and show him a Alert for that (app.alert.show).

I build the sugarcrm/custom/modules/Leads/clients/base/layouts/convert-main/convert-main.js file with this code.

The if-Statement works, and also the this._super('handleSave'); in the else case, but not in onConfirm action:

({
    extendsFrom: 'LeadsConvertMainLayout',

    initialize: function(options) {
        this._super('initialize',[options]);
        this.context.on('lead:convert:save', this.handleSave, this);
    },

    handleSave: function() {
       //
       // do some things ...
       //

      if (XYZ == true) {
            app.alert.show('myconfirm-msg', {
                level: 'confirmation',
                messages: 'Please confirm to save!',
                autoClose: false,
                onConfirm: function(){
                    this._super('handleSave');
                    // perform the normal handleSave -> this don't work
                },
                onCancel: function(){
                    // do nothing
                }
            });
      } else {
          this._super('handleSave'); // perform the normal handleSave - this works
      }
    },
})

 

Can you please help me how to solve this.

Many Thanks

Sven

Outcomes