Send mass email from list view in a custom module

Hello,

we’ve created a custom module and now we want to enable to send emails from the list view. Just like in the Contacts module we select records and navigate to the dropdown where you can merge and massupdate etc.

So we have to create a button that calls send_form_for_emails(). In the custom/modules/MODULE/views/view.list.php I’ve added the following:


public function preDisplay()
    {
        parent::preDisplay(); // TODO: Change the autogenerated stub
        $this->lv = new ListViewSmarty();
        $this->lv->moduleString = 'LOG1_Logistik';
        $this->lv->email = true;
    }

Which sould add a new option to the dropdown menu called E-mail.
Yet, buildComposeEmailLink() in /include/ListView/ListViewDisplay.php is called but


$dictionary[$this->seed->object_name]['relationships'][$field['relationship']]['rhs_module'] == 'EmailAddresses' 

is false so

 $foundEmailField

stays false and will not be set to true, which breaks out of this method and no email option is created.

So what I need to know is how I can add


$dictionary[$this->seed->object_name]['relationships'][$field['relationship']]['rhs_module'] == 'EmailAddresses' 

to this custom module?

By now I’ve tried to add vardefs like this:


/custom/Extension/modules/MODULE/Ext/Vardefs/sugarfield_email.php
$dictionary['LOG1_Logistik']['fields']['email_addresses'] = array(
    array(
        'name' => 'email_addresses',
        'type' => 'link',
        'relationship' => 'log1_logistik_email_addresses',
        'module' => 'EmailAddress',
        'bean_name' => 'EmailAddress',
        'source' => 'non-db',
        'vname' => 'LBL_EMAIL_ADDRESSES',
        'reportable' => false,
        'unified_search' => true,
    ),
);
$dictionary['LOG1_Logistik']['fields']['email_addresses_primary'] = array(
    'name' => 'email_addresses_primary',
    'type' => 'link',
    'relationship' => 'log1_logistik_email_addresses_primary',
    'source' => 'non-db',
    'vname' => 'LBL_EMAIL_ADDRESS_PRIMARY',
    'duplicate_merge' => 'disabled',
);
$dictionary['LOG1_Logistik']['fields']['emails'] = array(
    'name' => 'emails',
    'type' => 'link',
    'relationship' => 'emails_log1_logistik_rel', /* reldef in emails */
    'module' => 'Emails',
    'bean_name' => 'Email',
    'source' => 'non-db',
    'vname' => 'LBL_EMAILS',
    'studio' => array("formula" => false),
);
And in /custom/metadata/emails_beansMetaData.php
$dictionary['emails_beans']['relationships']['emails_log1_logistik_rel'] = array(
    'lhs_module'		=> 'Emails',
    'lhs_table'			=> 'emails',
    'lhs_key'			=> 'id',
    'rhs_module'		=> 'Tasks',
    'rhs_table'			=> 'tasks',
    'rhs_key'			=> 'id',
    'relationship_type'	=> 'many-to-many',
    'join_table'		=> 'emails_beans',
    'join_key_lhs'		=> 'email_id',
    'join_key_rhs'		=> 'bean_id',
    'relationship_role_column' => 'bean_module',
    'relationship_role_column_value' => 'LOG1_Logistik',
);

But

$dictionary[$this->seed->object_name]['relationships'][$field['relationship']]['rhs_module'] == 'EmailAddresses' 

still stays false / empty.

Any suggestions?

Kind regards,

Sebastian