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',[]);

    }})

  • I think I know the source of part of the problem here. I think each of us is talking about different parts of the problem.

    To clarify, there are two matters relating to the use of RLI entries. Assuming you are using a version prior to 7.6.0, upon one creating a new Opportunity, one would receive a prompt informing the user that they needed to create at least one RLI. A similar alert would appear if you happened to go to an existing Opportunity that didn't have at least one linked RLI entry. This is the first matter and is addressed by the code snippets that I referenced.

    In 7.6.0, the creation process changed a bit and now you can enter an RLI at the same time that you create the new Opportunity. This is where I think I got confused and thought you were talking about the alert I mention above. Given that the RLI entry panel is displayed as part of the new Opportunity window and some of its fields are required, it is not possible to create an Opportunity without also creating at least one RLI entry.

    If I now understand your goal correctly, what you want is to effectively remove the RLI panel from the Opportunity creation window so as to not force the user to create that entry, would that be correct? (And second to that, the removal of the alerts that will likely come back by way of no longer forcing the creation of that one RLI entry).

  • Angel, you are right on with this.  That's exactly the issue.  I had in the 7.5 disabled the warning message for customers.  But in 7.6 it's now required that you create an RLI.  I would just like that subpanel to go away in the Opp create screen.  I've tried altering subpanel-for-opportunity-create.php and that didn't help either.

    I'm digging in even deeper at this point.  Where I haven't tread before.    I'm open for hints.

    I will reply here if/when I figure out the solution.

  • You'll want to modify the create-actions layout for Opportunities, located here:

    ./modules/Opportunities/clients/base/layouts/create-actions/

    The metadata file (create-actions.php) will contain the following:

    $viewdefs['Opportunities']['base']['layout']['create-actions'] = array(

        'type' => 'create-actions',

        'name' => 'base',

        'span' => 12,

        'components' => array(

            array(

                'layout' => array(

                    'components' => array(

                        array(

                            'layout' => array(

                                'components' => array(

                                    array(

                                        'view' => 'create-actions',

                                    ),

                                    array(

                                        'layout' => 'subpanels-create',

                                    ),

                                ),

    In your version of this file, you should be able to get rid of the RLI panel by simply removing this snippet:

                                    array(

                                        'layout' => 'subpanels-create',

                                    ),

    Give that a try.

  • Thank you for your patience in working through it Angel.  That was the ticket, getting into that create-actions.php and commenting out those lines, then in the create-actions.js and the record.js making sure the warnings don't come up, and it's done!

    Thanks!

    --Eric

  • Is this upgrade-safe if you're directly editing a file not in the /custom directory?

    And for On Demand installing this through the Module Loader, is it possible to comment out that

        array(

              'layout' => 'subpanels-create',

        ),

    without overwriting the default file (perhaps uploading this to somewhere in /custom)?

  • Logan,

    Apologies, the point wasn't clear as the message was merely directing Eric to the file that would need to be customized. You would still need to make the change in the ./custom directory.

  • Hi Angel,

    Is there a way to keep RLI subpanel on Opportunity create view, BUT make it not required? As of now RLI has a couple required fields and does not allow you to save Opp without them completed, which means RLI created. If I make original RLI  module fields not required and save Opportunity with empty RLI fields, would it create empty RLI or there is another way to achieve this?

    Regards,

    Dmitrii

  • Hi Dmitrii Mikhalchenko 

    You can extend the controller modules/Opportunities/clients/base/views/create/create.js and override the method "getCustomSaveOptions". Basically you need to drop of the following line

    this._checkForRevenueLineItems(model, options);

    Kind regards

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • Hi Andre,

    thank you for you response. 

    But this does not work. I am getting message that some required fields are not populated. And those fields on RLI subpanel:

     - Products

     - Item status

    I don't want to set all the fields non required, as they should be required if you specify RLI.

    Regards,

    Dmitrii

  • You can setup a SetRequired dependency on RevenueLineItems in order to make those fields required if product_template_id is not empty.

    Cheers

    André Lopes
    Lampada Global
    Skype: andre.lampada
Reply Children