How do you bypass the requirement to create a Revenue Line Item before you can save an Opportunity?

Customer uses the Revenue Line Items, but doesn't want to be forced to create one in order to save the Opportunity, as this does not fit their process.  They want to create and save the Opp, then come back later and either enter or import the individual RLI records.

The admin section for Opportunities does not offer the RLI to be optionally added later.  The only choices are use the RLI or don't use RLI and then they go away entirely.

Is there a way anyone has found to bypass the requirement that you must create at least one RLI?

Parents
  • Guess no one has run into this situation yet?

    Anyone from Sugar Engineering that reads this stuff and can help?  At least a hint?  This is a big deal for this customer, and they are refusing upgrade to 7.6 until this is solved.

  • You can create a custom controller for the create-actions and record views that in turn would allow you eliminate the check for Revenue Line Items that is performed when you create a new opportunity and/or view an existing opportunity.

    The code for those would look something like this, respectively:

    create-actions.js

    ({

        extendsFrom: 'CreateView',

       

        getCustomSaveOptions: function(options) {

            this.createdModel = this.model;

            // since we are in a drawer

            this.listContext = this.context.parent || this.context;

            this.originalSuccess = options.success;

            var success = _.bind(function(model) {

                this.originalSuccess(model);

            }, this);

            return {

                success: success

            };

        },

        _dispose: function() {

            this._super('_dispose');

        }

    })

    record.js

    ({

        extendsFrom: 'RecordView',

        initialize: function(options) {

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

        },

        _dispose: function() {

            this._super('_dispose');

        },

    })

  • Angel, thank you for this.  I am going to try this later today.  I really appreciate the help!

  • Hi Angel.  Maybe I am doing something incorrectly on this.  I have modified the file you specify, and then installed it into:

    custom/modules/Opportunities/clients/base/views/create-actions/create-actions.js

    And I see no affect.  Either the custom file is not over riding the original file, or I am not looking at the correct lines to edit.  Even if I remove most of the lines in getCustomSaveOptions it has no affect.  Also, I did notice now (with all the original code) that when you try to save an Opp and you haven't filled in an RLI there is no warning message, it just highlights the "Likely" field in the RLI in the subpanel.  The code below shows an RLI Warning message that I never even see.

    Here is the file that is in my 7.6 install on OnDemand:

    ({extendsFrom:'CreateActionsView',

        createdModel:undefined,

        listContext:undefined,

        originalSuccess:undefined,

        alert:undefined,

        initialize:function(options){

            this.plugins=_.union(this.plugins,['LinkedModel']);this._super('initialize',[options]);

        },

        getCustomSaveOptions:function(options){

            if(app.metadata.getModule('Opportunities','config').opps_view_by==='RevenueLineItems'){

                this.createdModel=this.model;

                this.listContext=this.context.parent||this.context;

                this.originalSuccess=options.success;

                var success=_.bind(function(model){

                    this.originalSuccess(model);

                    var addedRLIs=model.get('revenuelineitems')||false;

                    addedRLIs=(addedRLIs&&addedRLIs.create&&addedRLIs.create.length);

                    if(!addedRLIs&&options.lastSaveAction!='saveAndCreate'){

                        this.showRLIWarningMessage(this.listContext.get('module'));

                    }

                },this);

                return{success:success};

            }

        },

        showRLIWarningMessage:function(){

            app.routing.before('route',this.dismissAlert,undefined,this);

            var message=app.lang.get('TPL_RLI_CREATE','Opportunities')

                    +'  <a href="javascript:void(0);" id="createRLI">'+

                    app.lang.get('TPL_RLI_CREATE_LINK_TEXT','Opportunities')+'</a>';this.alert=app.alert.show('opp-rli-create',{level:'warning',autoClose:false,title:app.lang.get('LBL_ALERT_TITLE_WARNING')+':',messages:message,onLinkClick:_.bind(function(){app.alert.dismiss('create-success');this.openRLICreate();},this),onClose:_.bind(function(){app.routing.offBefore('route',this.dismissAlert,this);},this)});

        },

        dismissAlert:function(data){

            if(data&&!(data.args&&data.args[0]==='Opportunities'&&data.route==='list')){app.alert.dismiss('opp-rli-create');app.routing.offBefore('route',this.dismissAlert,this);}

        },

        openRLICreate:function(){

           this.dismissAlert(true);

            var model=this.createLinkModel(this.createdModel||this.model,'revenuelineitems');

            app.drawer.open({

                    layout:'create-actions',

                    context:{create:true,module:model.module,model:model}

                },

                _.bind(function(model){

                        if(!model){return;}

                        var ctx=this.listContext||this.context;ctx.reloadData({recursive:false});

                        ctx.trigger('subpanel:reload',{links:['opportunities','revenuelineitems']});

                    },

                    this

                )

            );

        },

    _dispose:function(){

        if(this.alert){

            this.alert.getCloseSelector().off('click');

        }

    this._super('_dispose',[]);

    }})

  • That looks like the standard version of the create-actions.js file.

    This bit of code is the one that performs the check for the RLI entries:

    var addedRLIs=model.get('revenuelineitems')||false;

                    addedRLIs=(addedRLIs&&addedRLIs.create&&addedRLIs.create.length);

                    if(!addedRLIs&&options.lastSaveAction!='saveAndCreate'){

                        this.showRLIWarningMessage(this.listContext.get('module'));

                    }

    Where in the file system structure of your install was this version of create-actions.js found? Is the above referenced file your version of the customized controller or something else?

  • I pulled it directly from the backups that Sugar sent me of the OnDemand sandbox.  Grabbed it from modules/Opportunities/clients/views/create-actions/

    Here's what it looked like before I added some line returns for readability.  This looks the same as the one in your note:

    var addedRLIs=model.get('revenuelineitems')||false;addedRLIs=(addedRLIs&&addedRLIs.create&&addedRLIs.create.length);if(!addedRLIs&&options.lastSaveAction!='saveAndCreate'){this.showRLIWarningMessage(this.listContext.get('module'));}

    And that is the line I focused on.  I tried to remove it and I tried to just set it to true.  No effect.  Unless I did something wrong, of course. 

Reply
  • I pulled it directly from the backups that Sugar sent me of the OnDemand sandbox.  Grabbed it from modules/Opportunities/clients/views/create-actions/

    Here's what it looked like before I added some line returns for readability.  This looks the same as the one in your note:

    var addedRLIs=model.get('revenuelineitems')||false;addedRLIs=(addedRLIs&&addedRLIs.create&&addedRLIs.create.length);if(!addedRLIs&&options.lastSaveAction!='saveAndCreate'){this.showRLIWarningMessage(this.listContext.get('module'));}

    And that is the line I focused on.  I tried to remove it and I tried to just set it to true.  No effect.  Unless I did something wrong, of course. 

Children
No Data