The status options of Activities modules (Calls, Meetings, Tasks) are built in sugar dropdowns and are hard coded so that they will appear in either Activities subpanel or History subpanel.
This post will help you on how to manage custom status and set the conditions if it should appear on Activities or in History subpanel.
In this example, we will add a new status “Cancelled” to Task module. When task is set to this, it should appear in History subpanel to indicate that no further action is required. Make sure to add the new status first on Dropdown Editor.
The Easiest way: (not upgrade safe)
1. Go to modules/Tasks/metadata/subpanels/ForActivities.php and update the where condition for the subpanel.
'where' => "(tasks.status != 'Completed' AND tasks.status != 'Deferred' AND tasks.status != 'Cancelled')",
* We don’t want to include Cancelled tasks in Activities subpanel
2. Go to modules/Tasks/metadata/subpanels/ForHistory.php and update the where condition as well
'where' => "(tasks.status='Completed' OR tasks.status='Deferred' OR tasks.status='Cancelled')",
* This time we want to include all Cancelled tasks to be fetched and shown in History subpanel
3. Run Repair and Rebuild and we’re done.
The Upgrade safe way:
1. We need to make a copy of ForActivities.php and ForHistory.php from modules/Tasks/metadata/subpanels/ in custom/modules/Tasks/metadata/subpanels/ if not existing. We will rename the files as ForActivities2.php and ForHistory2.php. (You can set the name whatever you want)
2. Follow instruction on the Easiest way part and apply this to our new custom files. :)
3. To make our changes work, we have to override the Activities and History subpanel setup and use our custom files. In this example, we will start with the Leads module.
Go to custom/Extension/modules/Leads/Ext/Layoutdefs/ and create a a file override_subpanel.php (You can set the name whatever you want) and add the following codes:
$layout_defs['Leads']['subpanel_setup']['activities']['collection_list']['tasks']['subpanel_name'] = 'ForActivities2';
$layout_defs['Leads']['subpanel_setup']['history']['collection_list']['tasks']['subpanel_name'] = 'ForHistory2';
You will notice that we are overriding the subpanel setup of Activities and History subpanel for Leads module which is set in modules/Leads/metadata/subpaneldefs.php
* We need to apply this on every module that we want our changes for Tasks in Activities and History subpanel.
4. Run Repair and Rebuild and we’re done.
Changes are applicable to Meetings and Calls module as well. You just need to follow the instructions and change the module name used for the directories.
Reference: Tips & Tricks – Custom Activity Status Dropdowns