SugarCRM SupportProduct GuidesSugar DeveloperSugar Developer Guide 8.0CookbookRemoving the Account Requirement on Opportunities

Removing the Account Requirement on Opportunities

Overview

This will article covers how to remove the Account field from being required on the Opportunities module. 

Removing the Requirement in Configuration

By default, Sugar requires the accounts field to be populated on several modules. These modules include

  • Opportunities
  • Cases
  • Contracts

In order to remove this dependency, you will need to modify the require_accounts configuration in your  ./config_override.php.

$sugar_config['require_accounts'] = false;

The resulting file should look similar to:
IMAGE2-config_override.php_file

Removing the Requirement in Vardefs

Once you have updated your configuration, you may find the field is still required. This may be due to the module's vardefs array having the field's required attribute set to true. This will also need to be updated. Using the Opportunities vardefs as an example, we will need to do the following:

  • Create a custom file in the Opportunites Extension direcotry like ./custom/Extension/modules/Opportunities/Ext/Vardefs/no_account_required.php 
  • Set the content of this file so that the account_name field has required set to false
    <?php
    
    $dictionary['Opportunity']['fields']['account_name']['required'] = false;
    

Once completed, you will need to navigate to Admin > Repairs and run a Quick Repair & Rebuild

Removing the Requirement in View Metadata

If the Account field is still required after making these changes, this may be due to the views metadata having a the field's required attribute set to true. By default, account_name should not be set to required, but if you have created custom views, these may need to be updated. Using the Opportunities record view as an example, we will need to do the following:

  • Edit  ./custom/modules/Opportunities/clients/base/views/record/record.php with a text editor application.
  • Search for the account_name field in panel definitions of your record view.
  • Remove 'required' => true, from the account_name definition. If it doesn't already exist, you don't need to modify anything.
    ...
      'fields' => 
        array (
          0 => 
            array (
              'name' => 'account_name',
              'required' => false,
              ...

    Your resulting file should be:

    ...
      'fields' => 
        array (
          0 => 
            array (
              'name' => 'account_name',
              ...
  • These changes will only affect the record view for Opportunities. You may need to modify additional module layouts based on your use case. A list of other views you many need to modify for your module are shown below.

    • ./custom/modules/<module>/clients/base/views/list/list.php
    • ./custom/modules/<module>/clients/base/views/record/record.php
    • ./custom/modules/<module>/clients/base/views/dupecheck-list/dupecheck-list.php
    • ./custom/modules/<module>/clients/base/views/resolve-conflicts-list/resolve-conflicts-list.php
    • ./custom/modules/<module>/clients/base/views/selection-list/selection-list.php
    • ./custom/modules/<module>/clients/base/views/subpanel-list/subpanel-list.php

Once completed, you will need to navigate to Admin > Repairs and run a Quick Repair & Rebuild

Application

Now that the appropriate changes have been made, navigate to the Opportunities module and create a new opportunity record. You will notice that the Account Name field no longer indicates "Required" in the field. In addition, the Account Name field will no longer be marked as required when importing records into the Opportunities module.
Opportunity_AccountNameField_NotRequired

Last modified: 2019-05-07 18:35:14