AnsweredAssumed Answered

Compose Emails from subpanel with populating the "Body", Case Module

Question asked by MIAG-CRM MIAG-CRM on Sep 28, 2015
Hi Experts,

We use the Sugar 6.5.4 enterprise Version. I Am not really deep familiar with the Sugar architecture, just a bit more than basics. Currently I'm working with the "Cases" module. When I click on the "Compose Email". button I would like to pre populate the email body with some fields from the case related to.

The field should shown in certain cases (if another field has a defined input - same record).  If you are able to help, it would very nice to know, where (paths) i need to add the code.  Thank you very much for having an eye on that.

I got already an approach from FrancescaS which is as follows:
copy modules/Emails/Compose.php  to
edit its name to something like 


I saved the following script.


if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

class SugarWidgetSubPanelTopCaseComposeEmailButton extends SugarWidgetSubPanelTopButton


var $form_value = '';

public function getWidgetId()


global $app_strings;

$this->form_value = $app_strings['LBL_COMPOSE_EMAIL_BUTTON_LABEL'];

return parent::getWidgetId();


function display($defines)


if((ACLController::moduleSupportsACL($defines['module']) && !ACLController::checkAccess($defines['module'], 'edit', true) ||

$defines['module'] == "Activities" & !ACLController::checkAccess("Emails", 'edit', true))){

$temp = '';

return $temp;


global $db,$app_strings,$current_user,$sugar_config,$beanList,$beanFiles;


$title = $app_strings['LBL_COMPOSE_EMAIL_BUTTON_TITLE'];

//$accesskey = $app_strings['LBL_COMPOSE_EMAIL_BUTTON_KEY'];

$value = $app_strings['LBL_COMPOSE_EMAIL_BUTTON_LABEL'];

$parent_type = $defines['focus']->module_dir;

$parent_id = $defines['focus']->id;

//Get Case information, queue will be needed to set the from address

$case = new aCase;


$unique_id = 'email_' . $case->id;

$composeData = array("parent_id" => $parent_id, "parent_type"=>$parent_type);

$j_quickComposeOptions = generateCustomComposeDataPackage($composeData, FALSE, FALSE);

$button = "<input title='Compose Email' id='{$unique_id}' onclick='SUGAR.quickCompose.init($j_quickComposeOptions);' class='button' type='submit' name='Compose Email' value='Compose Email' />";

return $button;



With the CustomCompose button on the activities subpanel for Cases I completed the whole thing

The button is there, On click "Quick Compose" opens, but unfortunately the related fields from the Case are not populated ("to_email_addrs", subject, Case relation, body)

If i set the Input argument "forFullCompose" to TRUE the compleate email mask apears in top of the subpanel, and all related fields are filled in the right places. Also the one which I need in the Body content.... What I'm doing wrong? The email composer should only open when i click on the "compose email" button...

It would be very kind of you, If you could have a short look on it. 
Thank you so much!