Process Definition not Triggered from $bean->save()

Hi everyone.

I am struggling to figure out why, but a process definition that uses the "Changes" method is not firing when a logic hook is using $bean->save(). The changes is a simple "No to Yes" but when saving the record it doesn't go into the processes.

I tried doing:


$dataChanges = $bean->dataChanges;
$bean->save();
$bean->dataChanges = $dataChanges;

But seemingly had no luck. Has anyone seen this before?

Thanks

Dan

  • Hi Maryam. 

    The code I provided is using the $bean->ignore_update_c so the code is not saving more than once. I don't think this is the issue for what I am experiencing.

    Thanks,

  • I am unable to understand that why you are added the following lines in your code:
    $bean->ignore_update_c = true;
    $dataChanges = $bean->dataChanges;
    $bean->save();
    $bean->dataChanges = $dataChanges;

    What is the purpose? You are not updating anything in bean apart from ignore_update_c and ignore_update_c need to use when calling save. So you should not use both. 

    It is like you have added both a problem and a solution by ownself. 

  • Hi Maryam.

    The function "checkForAcpFieldChanges" uses stored rows to check if data has changed:

    e.g.

    Fullscreen
    1
    2
    3
    4
    if ((isset($bean->stored_fetched_row_c) && $bean->stored_fetched_row_c["$crmField"] != $bean->$crmField) && $bean->acp_update_c != 1)
    {
    $bean->acp_update_c = 1;
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    I think I understand what you are saying now, but how do I set the $bean to recognise a field change without calling $bean->save() in the after save?

  • Hi - I just want to say a massive thank you! I never even realised you could process the whole record in before_save, that solves so many other issues.

    For anyone else reading, "Fetched Row" gets the before value and the $bean in before_save actually has the new value!

  • For data changes why you are not getting this info from arguments?

    function contactsAfterSave($bean, $event, $arguments) {

           $arguments['dataChanges']['YourFieldName']['before']   //contains old value

           $arguments['dataChanges']['YourFieldName']['after']   //contains new value

    }

    By this, you will simply recognize :) 

  • Welcome :)

    Yes, For before_save logic hook it is the flow.
    For the after_save logic hook, we need to look into the $arguments for getting old and new values.

1 2