Add any field to Mass Update in SugarCRM CE | SuiteCRM

Before we start I want to make it clear that this is a Non-Upgrade Safe modification.

Credit to Jason Eggers for originally describing how to do this in this forum post.

By default SugarCRM only allows custom fields of the following types to be mass up-datable :

  • Bool
  • Enum
  • Multienum
  • radioenum
  • datetime
  • date

So if you want add non mass up-datable fields or custom fields to the mass update form for a specific module then you have to make some non-upgrade safe changes to the following file:

include/MassUpdate.php

Edit the getMassUpdateForm() function and add the code after this comment

/** Modification: add custom fields like this */

:

switch($field["type"]){
 case "relate": $even = !$even; $newhtml .= $this->handleRelationship($displayname, $field); break;
 case "parent":$even = !$even; $newhtml .=$this->addParent($displayname, $field); break;
 case "contact_id":$even = !$even; $newhtml .=$this->addContactID($displayname, $field["name"]); break;
 case "assigned_user_name":$even = !$even; $newhtml .= $this->addAssignedUserID($displayname, $field["name"]); break;
 case "account_id":$even = !$even; $newhtml .= $this->addAccountID($displayname, $field["name"]); break;
 case "account_name":$even = !$even; $newhtml .= $this->addAccountID($displayname, $field["id_name"]); break;
 case "bool": $even = !$even; $newhtml .= $this->addBool($displayname, $field["name"]); break;
 case "enum":
 if(!empty($field['isMultiSelect'])){
 $even = !$even; $newhtml .= $this->addStatusMulti($displayname, $field["name"], translate($field["options"])); break;
 }else{
 $even = !$even; $newhtml .= $this->addStatus($displayname, $field["name"], translate($field["options"])); break;
 }
 case "date":$even = !$even; $newhtml .= $this->addDate($displayname, $field["name"]); break;

 }

 /** Modification: add custom fields like this */
 if($field["type"] == "url" && $field["name"] == "field_name") {
 $even = !$even;
 $newhtml .= $this->addField($displayname, $field["name"]);
 } 

Above I am adding a field of type url but this could be any field type.

Now add the following function to the bottom of the MassUpdate class:

 //Add fields to the Mass Update screen
 function addField($displayname, $varname){

 global $app_strings, $app_list_strings, $theme;

 $html = <<<EOQ
 <td width="15%" scope="row" >$displayname</td>
 <td><input name='$varname' id='{$varname}' /></td>
EOQ;

 return $html;
 }

The next thing we need to do is set the massupdate parameter to true in the vardefs for the field.

If its a custom field that you added through studio then simply go into your sugar database and then the fields_meta_data table and find the row entry for your custom field.
Change the massupdate field from 0 to 1.

If its not a custom field added through studio then create a custom php file in this location:

/custom/Extention/modules/<BeanName>/Ext/Vardefs/any_name.php

and then add the following code for your specific field.

$dictionary['<BeanName>']['fields']['<field_name>']['massupdate'] = 1;

Finally run a repair/rebuild and your field should be available on mass update panel.

Andy
About

Software Developer from Falkirk, Central Scotland.

Posted in SugarCRM development and customisation, SugarCRM development development hints and tips
4 comments on “Add any field to Mass Update in SugarCRM CE | SuiteCRM
  1. hello

    Segui steps tutorial and it works. There is a question that I have problems. When the field is enabled with the “massupdate” attribute and rebuild, appears in the panel two fields.

    One is adding sugar to “massupdate” and the other which is added to the function “addField”.

  2. luggie says:

    Doesn’t work for me. Might be because I’m still using SugarCRM 6.2.2

  3. Maks says:

    Hello!
    Can I add checkbox to STUDIO for add params ($dictionary['']['fields']['']['massupdate'] = 1) for any fields ?

Leave a Reply to Maks Cancel reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>