Hi cefladental,
Since my post, I thought of a solution and tried it on a test server. I'll probably use it on our production SugarCRM instance.
The best way to assign cases to someone who is responsible of a client is probably by a Logic Hook. I wrote a simple Logic Hook who check the user assigned to the client and then assign the case to that same user. An optional way to proceed is by having an array of clients and users like the one in comments in the code below.
Code:
class UpdateAssignedUserID
{
function updateAssignedUserID(&$bean, $event, $arguments)
{
global $db;
// Array of clients and users - not used anymore
/*$clientsUsers = array(
"2a2b81d3-9b70-067b-c56f-4d9b348cf330" => "d71fd47a-3e87-5e74-82f9-4d9c894ce647",
"5ce004fd-973b-4fdd-e742-4d9c7a661771" => "2ea2f7db-d909-8995-7226-4d9c7cfeb422");*/
// Select all accounts id and assigned users
$query = "SELECT accounts.id, accounts.assigned_user_id FROM accounts";
$results = $db->query($query, true);
$rowNumber = 0;
$clientsUsers = Array();
// Copy each row in an aray
while ($row = $db->fetchByAssoc($results, $rowNumber))
{
$clientsUsers[$row['id']] = $row['assigned_user_id'];
$rowNumber++;
}
// Find which client and assign the responsible user
foreach ($clientsUsers as $clientID => $userID)
{
if ($bean->account_id == $clientID)
{
$bean->assigned_user_id = $userID;
}
}
}
} EDIT: I reread your post and you say that you are talking about sending an email to the person who is responsible of the client. You can use a similar logic. You can loop through your clients to find the user you need and then send him an email. Here is a thread about sending an email in a logic hook: http://www.sugarcrm.com/forums/showthread.php?t=65541
Bookmarks