HOWTO: Making upgrade-safe changes to the History subpanel

sugarcrmdevelopers —  July 11, 2011 — 8 Comments

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.

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

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

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

Remember that you have to run a Quick Repair and Rebuild before the changes will take effect.

8 responses to HOWTO: Making upgrade-safe changes to the History subpanel

  1. 
    Cedric Mourizard August 3, 2011 at 2:21 pm

    Hi,

    If you want to push your subpanels definition in custom directory you should to put the “override_subpanel_name” and not the “subpanel_name” entry in your definition

  2. 

    Why you redefine subpanel – ForHistory2 instead ForHistory?
    You can override ForHistory.php template only – if put it to custom/modules//metadata/subpanels/ForHistory.php

  3. 

    The .zip file does not download, why?

  4. 

    Is it me or is there no explanation whatsoever what the history_change.php file is for?

  5. 

    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).

    Thanks Vincent

Trackbacks and Pingbacks:

  1. Notes SubPanel Customization (On Cases) SugarPro - May 27, 2013

    […] […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s