Relate field not showing in audit log after saving through the logic hook in version 10.

Hi everyone,

I have a related field and saving it through the logic hook. After saving it is not showing in the audit log in version 10 and the field is selected with audit in the studio.

It works fine when we save it normally in the module but getting an issue with the logic hook.

Please suggest a solution.

Thanks

Laxmi Chand Saini

Parents Reply
  • Hi Laxmichand,

    The record which you are trying does it have related account in contact initially, if so pls add global statement once and check once. Or else you can replace the first line in code with

     if($bean->fetched_row['account_id'] != $bean->account_id) 

    and add one global statement and check whether it is entering into if condition or not.

    This Logic Hook should use before_save trigger. Let me know how it goes for you.

     

Children
  • Sorry missed one more thing, please try this code in auditAcc.php. Please check if you are able to get these two statements printed in logs or not.

    <?php
    class auditAccC
    {
    function auditAccF($bean)
    {

    $GLOBALS['log']->fatal("printing fetched row account id" . $bean->fetched_row['account_id']);

    $GLOBALS['log']->fatal("printing current account id" . $bean->['account_id']);

    // check for the change
    if ($bean->fetched_row['account_id'] != $bean->account_id)
    {

    $GLOBALS['log']->fatal("entered into if condition");

    // prepare an array to audit the changes in parent module's audit table
    $aChange = array();
    $aChange['field_name'] = 'account_id';
    $aChange['data_type'] = 'relate';
    $aChange['before'] = $bean->fetched_row['account_id'];
    $aChange['after'] = $bean->account_id;
    // save audit entry
    $bean->db->save_audit_records($bean, $aChange);
    }
    }

    Please try this code and perform QRR and check once. Let me know how it goes for you this time.