Disabling 'Account Name' as required only in Opportunities Subpanel

Hello everyone :slight_smile:

After creating a one to many relationship between Leads and Opportunities now Iā€™m able to see the Opportunities Subpanel in Leads module.

As many of you know, I had to add

$sugar_config[ā€˜require_accountsā€™] = false;

in order to be able to add opportunities without an account.

The question is, thereā€™s any way to make this field not required only in Leads subpanel ?

I want the ā€˜account nameā€™ required if a user creates an opportunity directly from the Opportunities module.

Thanks!

PS: Iā€™m working with 7.11.18 btw

Hey there,

I donā€™t believe it is something that could be done OOTB, Iā€™m afraid.

However, if you are still looking for this, Iā€™ve had a look.

I believe I was able to achieve this via custom code:
(Though if someone finds any errors, please let me know!)


Create a new file at:
custom/modules/Opportunities/views/view.subpanelquickcreate.php

and paste in the following:

<?php

require_once('include/EditView/SubpanelQuickCreate.php');

class OpportunitiesSubpanelQuickCreate extends SubpanelQuickCreate
{
    public function OpportunitiesSubpanelQuickCreate(){


        //If Module is Currently Leads->Opportunities Subpanel
       if ($_POST["return_module"] == "Leads"){
      
        // Begin Js Script - Use RemoveFromValidate Function
        $jsscript = <<<EOQ
                                <script>
                                removeFromValidate('form_SubpanelQuickCreate_Opportunities','account_name');
                                </script>
EOQ;

// Echo JsScript onto Page
        parent::SubpanelQuickCreate("Opportunities");
        echo $jsscript;

       }

// If parent module is not Leads, continue as normal
       else{

        parent::SubpanelQuickCreate("Opportunities");

       }
    }
}



The above code should make the ā€œAccount Nameā€ field non-required ONLY when on the Leads->Opportunities subpanel

Please let me know if you have any issues!