SugarCRM Developers on Twitter

HOWTO: Making upgrade-safe changes to the History subpanel

Editor’s Note: This post comes from the work of Ken Brill, who comes from the Sugar Community and has been a part of the SugarCRM family for the past few years in the Support team and is now one of our Professional Services consultants. He’s done many many many ( I can’t provide enough many’s here 🙂 ) customizations to SugarCRM and has provided numerous contributions to the code base itself. This post comes from a forums post he did a few months back, detailing how to make upgrade-safe changes to the History subpanel, which is often a tricky thing to do for many SugarCRM developers.

I get asked this all the time and I couldn’t find anywhere that put it all together in one place very well, so here is my attempt.

What I want to do it put ‘date_start’ in place of ‘date_modified’ in the history subpanel as the modified date of a meeting or call isnt very useful. So here is how you do it in an upgrade safe way

First create a file called

custom/Extension/modules/Accounts/Ext/Layoutdefs/history_change.php

Now, of course if you wanted to change the history subpanel in Contacts or Cases then you would have to modify the path of the file and the contents accordingly.

What I am doing there is overriding the name of the subpanel definition file for each of the elements that makes up a history subpanel. Instead of pointing to ‘ForHistory.php’ I changed it to ‘ForHistory2.php’ and that new file will also live in the custom/ directory. So lets look at them now.

Create another new file called

custom/modules/Meetings/metadata/subpanels/ForHistory2.php

The only difference between this file and the stock ForHistory.php file is that date_start replaces date modified.

'date_start'=>array(
'vname' => 'LBL_DATE',
'width' => '10%',
),

Now thats great for Meetings, Calls and Tasks as they all have a date_start field in them, what about Notes and Emails? Well thats easy, lets look at Notes first.

In that array (named custom/modules/Notes/metadata/subpanels/ForHistory2.php) we replace the date_modified tag with a new one.

Since there is no date_start we “make” one (thats what ‘force_exists’ does), Now I think we could have left this one alone and it would, by default, show the date_modified but it would be labelled ‘Date Start’ and I thought that would be confusing. This way there will be a blank cell here as Notes dont have Date Start.

Now for Emails, what we want is Date Sent, so I am going to forgo my worries about confusion and just put the date_sent value under date_start.
Like this in

custom/modules/Emails/metadata/subpanels/ForHistory2.php

In this file we replace

'date_modified' => array(
'width' => '10%',
),

with

'date_sent' => array(
'width' => '10%',
),

and remember that you have to do the same thing for unlinked emails in

hI I am following your example indeed, the problem is that date_start is already present in the ForHistory.php file. I added a custom field and managed to get it right, I was able to remove date_modified as well, but I struggle to add the date_start field. Any suggestion? I am using SuiteCRM 7.5.1 based on Sugar Versione 6.5.20 (Build 1001).