Hello,
I'm trying to set up a double opt in/opt out solution for my company's newsletter. For the opt out process, I have a script that the unsubscribee (Lead) can run from their email that changes a custom checkbox field. I have a Workflow definition that, when it notices this field has changed, runs its alerts/actions. I would like it to change the field opt_out in the Lead's related email to be true, and I set up the workflow definition as such, but it just doesn't. It appears that the email address relationship doesn't get recognized, as I can change fields in other related modules, just not Email Addresses. At the very least I know the Lead has the correct email address, as in the same workflow definition I can send an alert email to the recipient (and even place the email address as a variable in the template) but as far as the actual relationship is concerned, I can't tell if its there (I'm using Sugar On Demand so I don't have direct database access to the email_addr_bean_rel table to see if its there). Anyone able to recreate this situation or tell me what I'm doing wrong?
Further information:
I'm working in SugarCRM Pro 6.
Workflow looks like this:
Execution Occurs: When record saved Status: Active
Target Module: Leads Applies to: Existing Records Only
Processing Order: Actions then Alerts
Conditions
Description: Value:
When double opt changes to or from specified value Equals Yes
These operations will be performed:
Alerts
Details Type: Event Description:
Actions
Details Type: Event Description:
Show Actions Update field(s) in a related EmailAddress
Show Actions Update fields in the target module
I'll have it be known that the second action does fire, just not the first.
What's more, this problem also seems to be in the SOAP interface. Here's the code I use to fire the above workflow:
Note that the set entry call works here. If I try to solve the email address problem using SOAP, I can retrieve the email address, but I can't seem to modify it. Code below:PHP Code://Find this Lead based off the email address
$search_by_module_params = array(
'user_name' => $username,
'password' => $password,
'search_string' => $_REQUEST['email'],
'modules' => array('Leads'),
'offset' => 0,
'max_results' => 1
);
$search_by_module_result = $client->call('search_by_module', $search_by_module_params);
$entry_id = $search_by_module_result['entry_list'][0]['id'];
//Set the double opt out parameter to true. SugarCRM should recognize this and run an
//internal script to opt out the email associated with this lead.
$set_entry_params = array(
'session' => $session_id,
'module_name' => 'Leads',
'name_value_list' => array(
array('name' =>'id',
'value' => $entry_id),
array('name' => 'double_opt_c',
'value' => 'true')
)
);
$set_entry_result = $client->call('set_entry', $set_entry_params);
The script returns the following:PHP Code://Get all the entries with the same email address as the email address provided
$get_entry_list_params = array(
'session' => $session_id,
'module_name' => 'EmailAddresses',
'query' => 'email_address=\''.$_REQUEST['email'].'\'',
'order_by' => '',
'offset' => 0,
'select_fields' => array('id', 'email_address', 'opt_out'),
'max_results' => 10,
'deleted' => 'false');
$get_entry_list_results = $client->call('get_entry_list', $get_entry_list_params);
$entry_id = $get_entry_list_results['entry_list'][0]['name_value_list'][0]['value'];
//Lets double check this is the right email
$get_entry_params = array(
'session' => $session_id,
'module_name' => 'EmailAddresses',
'id' => $entry_id,
'select_fields' => array('email_address'));
$get_entry_results = $client->call('get_entry', $get_entry_params);
foreach($get_entry_results['entry_list'][0]['name_value_list'][0] as $key2 => $value2)
{
echo '--'.$key2.' => '.$value2.'<br/>';
}
echo "<br/>";
$set_entry_params = array(
'session' => $session_id,
'module_name' => 'EmailAddresses',
'name_value_list' => array(
array('name' =>'id',
'value' => $entry_id),
array('name' => 'opt_out',
'value' => 'true')
)
);
$set_entry_result = $client->call('set_entry', $set_entry_params);
foreach($set_entry_result['error'] as $key => $value)
{
echo $key.' => '.$value.'<br/>';
}
This means its correctly finding the email address and I can access the email address by id, and its saying it has no error in the set_entry command. However, when I go into the Lead record, the opt out field is still false.HTML Code:--name => email_address<br/> --value => test@test.com<br/> <br/> number => 0<br/> name => No Error<br/> description => No Error<br/>


LinkBack URL
About LinkBacks



Reply With Quote

Bookmarks