AnsweredAssumed Answered

Record sync issue after logic hook

Question asked by Francesca Shiekh on Jan 13, 2017
Latest reply on Jan 3, 2019 by Francesca Shiekh

1. Open a case.
2. Send an email 
3. Return to case.
4. Update any field - you get the "resolve conflict page".


This seems to be caused by a custom after_relationship_add logic hook on Emails.

When the email is saved (depending on some custom parameters) the Case Status is changed but does not appear changed in the interface when the Email drawer is closed. When the user then changes any other field they receive a conflict.

The resolve conflict window suggests that the logic hook change happened *after* my edit of the Case.


Logic hook example: if the case was unassigned (customization has all new cases unassigned) it is then assigned to the person who answered it:


class email_case_handling
   // Email RELATED to a case
   function update_on_relationship ($bean,$event,$arguments){
        //bean = Email
        //case retrieved from related_id
        global $current_user;
        $today = TimeDate::getInstance()->nowDb();
        if ($arguments['related_module'] =='Cases'){
           $case = BeanFactory::retrieveBean('Cases', $arguments['related_id']);
           < some other stuff....>
           if($case->assigned_user_id == '' && $case->status == 'New'){
              //if the case is still unassigned and new, assign to whomever sent the case
              $case->assigned_user_id = $current_user->id;
              $case->status = 'Assigned';
           < some other stuff....>


Any thoughts on how to address this?