bean not in if condition even logic is correct in logic hook

Hi,

a weird thing in my system

I have logic_hook in opportunities module after_save

but one record always not in a condition, I'm not sure why.

could you please suggest how should I investigate a problem?

logic: when change assignee from Admin to any user, do orange and green.

but weird not doing orange.

This logic for orange.

- is update

- assigned user id before not equal after

- not Admin

if (
        $arguments['isUpdate'] == true &&
        $arguments['dataChanges']['assigned_user_id']['before'] != $arguments['dataChanges']['assigned_user_id']['after'] &&
        $bean->assigned_user_id != 1
){
// do orange and green
}

log show:

user 1 (top) normal user

user 2 (bottom) weird user id = 1f99f0d8

Sugar 9 Pro

Thanks,

M

Parents Reply
  • One more thing, if you are checking that record's assign must update from Admin to normal User than you must need to add one more AND condition because currently, it is also true if the record will update from a normal user as well. 

    if (
            $arguments['isUpdate'] == true &&
            
    $arguments['dataChanges']['assigned_user_id']['before'] == 1 &&
            $arguments['dataChanges']['assigned_user_id']['before'] != $arguments['dataChanges']['assigned_user_id']['after'] &&
            $bean->assigned_user_id != 1
    ){
    // do orange and green
    }
Children
No Data