I have created another field with name emailtotext_c.
The code is given below where I have reached :
if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once('data/SugarBean.php');
require_once('include/SugarPHPMailer.php');
class work_flows{
function work_flows_execute(&$bean, $event, $arguments)
{
$link = "Support_Cases_emailtotext_c";
if ($bean->load_relationship($link))
{
$relatedBeans = $bean->$link->getBeans();
foreach($relatedBeans as $relatedBean)
{
$contact_id = $relatedBean->id;
$contact = BeanFactory::getBean('Contacts', $contact_id);
$contact_email = $contact->emailAddress->getPrimaryAddress($contact);
$bean->emailtotext_c = $contact_email;
}
}
}
I am having confusion what to add in the $link variable. It is only sending email to primary address but not on the field I created.
And What to do next to make it workable ?