AnsweredAssumed Answered

assigned_user_id doesn't change...

Question asked by Robert Sinclair on Nov 22, 2018
Latest reply on Nov 23, 2018 by Robert Sinclair

Hello

 

Would really appreciate your help. Very confusing issue. It's gotta be something simple I'm sure, I'm just not seeing it.

 

I have a before and after save hooks which simply check if the assigned user ID has changed. But I'm getting the same user_ID in the before AND the after save hooks.

 

Logic Hook registry

 

$hook_array['before_save'] = Array();
$hook_array['before_save'][] = Array(
77,
'If a new user is assigned to the unit of inventory it changes inventory status to OFFER',
'custom/modules/un_inventory/user_assigned_c.php',
'user_assigned_c',
'user_assigned_before_save');
$hook_array['after_save'] = Array();
$hook_array['after_save'][] = Array(
77,
'If a new user is assigned to the unit of inventory it changes inventory status to OFFER',
'custom/modules/un_inventory/user_assigned_c.php',
'user_assigned_c',
'user_assigned_after_save');

and the actual hook

 

class user_assigned_c {
  
    function user_assigned_before_save($bean, $event, $arguments) {

        $GLOBALS['log']->info('User ID before save: '.$bean->assigned_user_id);

    }

    function user_assigned_after_save($bean, $event, $arguments) {
        // $bean->assigned_user_id stays the same as in the method above...
        $GLOBALS['log']->info('User ID after save: '.$bean->assigned_user_id);
    }

}

Outcomes