SugarCRM SupportKnowledge BaseStudio and Module BuilderAdding a Field to Mass Update

Adding a Field to Mass Update

Overview

Mass updating in Sugar® allows users to easily update multiple records at one time from the module's list view. Out of the box, there are a number of stock fields that are enabled for mass update. However, there may be occasions when you need to enable this option for other fields in Sugar. This article will cover how to enable fields and relationship fields for mass update Some fields can be enabled via Admin > Studio while others will require code-level customization.

Prerequisites

  • For some field types, you must have administrator or developer access in Sugar to make the necessary changes in Studio.
  • For other field types, you must have direct access to the server hosting your instance in order to make the necessary changes via code-level customization. 

Steps to Complete

Enabling Fields for Mass Update Via Studio

In Sugar, stock and custom fields of the following field types can be enabled for mass update via Admin > Studio:

  • Date
  • DateTime
  • DropDown
  • MultiSelect
  • Radio

The following steps cover enabling mass update for the Salutation field in the Contacts module as an example:

  1. Navigate to Admin > Studio > Contacts > Fields and click the Salutation field.
    Studio Fields Salutation
  2. Check the Mass Update checkbox under the Edit Fields tab.
    KB Check MassUpdateOption
  3. Click "Save" to preserve the change.

Once the change has been saved, navigate to the Contacts module and you should now see the Salutation field available to select in the Mass Update panel. For more information on mass updating, please refer to the User Interface documentation.
KB FieldAvailable MassUpdate

Enabling Fields for Mass Update Via Customization

The Mass Update option can also be enabled via code-level customization for field types that cannot be enabled in Studio. Please note that there is a known enhancement request regarding the ability to enable mass update for all field types in Sugar. The following field types can be configured for mass update via code-level customization:

  • Address
  • Checkbox
  • Currency
  • Decimal
  • Encrypt
  • Float
  • HTML
  • IFrame
  • Image
  • Integer
  • Phone
  • Relate
  • TextArea
  • URL
  • TextField

For stock and custom fields that cannot be enabled for mass update via Admin > Studio, you will need to make the necessary change via code-level customization. If you wish to enable mass update for stock fields (e.g. Billing Country), you must navigate to Admin > Studio > {Module Name} > Fields and re-save the specific field. This will create a file in ./custom/Extension/modules/{module}/Ext/Vardefs/ where you can make the necessary code-level customization. For any new fields created in Sugar, the file in ./custom/Extension/modules/{module}/Ext/Vardefs/ will be created automatically.

For example, if you create a custom checkbox field "checkboxfield1" in Studio, it will create a file such as ./custom/Extension/modules/Accounts/Ext/Vardefs/sugarfield_checkboxfield1_c.php.  

The file for the custom checkbox field will contain code similar to this:

<?php
// created: 2015-07-21 14:56:21
$dictionary['Account']['fields']['checkboxfield1_c']['labelValue']='checkboxfield1';
$dictionary['Account']['fields']['checkboxfield1_c']['enforced']='';
$dictionary['Account']['fields']['checkboxfield1_c']['dependency']='';

?>

To enable mass update for the field, you will need to add a line similar to this with "YourModule" and "yourfield_c" replaced with your actual values:

$dictionary['YourModule']['fields']['yourfield_c']['massupdate']=true;

For our example, we will add the following line of code to enable mass update for our example checkbox field:

$dictionary['Account']['fields']['checkboxfield1_c']['massupdate']=true;

The updated file should look similar to this:

<?php
// created: 2015-07-21 14:56:21
$dictionary['Account']['fields']['checkboxfield1_c']['labelValue']='checkboxfield1';
$dictionary['Account']['fields']['checkboxfield1_c']['enforced']='';
$dictionary['Account']['fields']['checkboxfield1_c']['dependency']='';
$dictionary['Account']['fields']['checkboxfield1_c']['massupdate']=true;

?>

Once the necessary change has been made, please navigate to Admin > Repair and perform a "Quick Repair and Rebuild" to ensure that the changes are synced between the application and database. Navigate to the Accounts module and you should now see the custom checkbox field available to select in the Mass Update panel. For more information on mass updating, please refer to the User Interface documentation.
MassUpdatePanel CheckboxField 

Enabling Relationship Fields for Mass Update Via Customization

Relationships define the links between different modules in Sugar and allow records between those modules to be related. For example, when a custom one-to-many relationship is created between Accounts and Bugs, a relationship field called Accounts will be created in the secondary module, Bugs, since each bug can relate to only one account. For more information on relationships, please refer to the article Introduction to Relationships and Relate Fields. Creating a one-sided relationship will place a file in ./custom/Extension/modules/{module}/Ext/Vardefs/ as described in the section above. However, the layout of the file will be slightly different.

For our example of an Accounts relationship field on the Bugs module, the file will contain code similar to this:

<?php
// created: 2015-07-21 17:20:55
$dictionary["Account"]["fields"]["accounts_bugs_1"] = array (
'name' => 'accounts_bugs_1',
'type' => 'link',
'relationship' => 'accounts_bugs_1',
'source' => 'non-db',
'module' => 'Bugs',
'bean_name' => 'Bug',
'vname' => 'LBL_ACCOUNTS_BUGS_1_FROM_BUGS_TITLE',
'id_name' => 'accounts_bugs_1bugs_idb',
);

To enable mass update for the field, you will need to add the following line of code to the array:

'massupdate' => 'true',

The updated file should look similar to this:

<?php
// created: 2015-07-21 17:20:55
$dictionary["Account"]["fields"]["accounts_bugs_1"] = array (
'name' => 'accounts_bugs_1',
'type' => 'link',
'relationship' => 'accounts_bugs_1',
'source' => 'non-db',
'module' => 'Bugs',
'bean_name' => 'Bug',
'vname' => 'LBL_ACCOUNTS_BUGS_1_FROM_BUGS_TITLE',
'id_name' => 'accounts_bugs_1bugs_idb',
'massupdate' => 'true',
);

Once the necessary change has been made, please navigate to Admin > Repair and perform a "Quick Repair and Rebuild" to ensure that the changes are synced between the application and database. Navigate to the Bugs module and you should now see the Accounts relationship field available to select in the Mass Update panel. For more information on mass updating, please refer to the User Interface documentation.
00000970

Last modified: 05/18/2018 12:03pm