Fetched Row Not Working on Relate Field Logic Hook

Hi Everyone,

Is it possible to use the fetched_row function on relate field (not relationship)?  

Currently we have the code below written in a before save logic hook, but the current account field is not pulling back a value using fetched_row.

$currentAccount = $bean->fetched_row['account_user_c'];
$GLOBALS['log']->fatal('Current Account: ' . $currentAccount);
$newAccount = $bean->account_user_c;
$GLOBALS['log']->fatal('New Account:: ' . $newAccount);

Any suggestions? Thanks!

Parents
  • Hello Dan,

    By design, the text value for the related field may fetch incorrectly for before_save.
    However, there is a solution.

    Below is the Logic Builder flowchart design for the before_save logic hook that logs "account_user_c" Relate type record data

    Please note, that by logging not only the account_user_c" changes but also an ID for that relate field, you will find both ID values, previous and new, are fetched correctly.

    Therefore in the flowchart, the previous and new IDs are used to retrieve FullNames of the users to solve your task.

    here are the results in the Log:

    As you can see, the previous user ID is "seed_sally_id" and FullName is "Sally Bronsen", while the new user id is "seed_will_id" and FullName is Will Westin

    In the same time, the previous and new "account_name_c" values are incorrect, so please do not rely on them

    I hope this helps

    Best Regards,
    Dmytro Chupylka

    integroscrm.com
    We make work in Sugar CRM system faster, more convenient and efficient

Reply
  • Hello Dan,

    By design, the text value for the related field may fetch incorrectly for before_save.
    However, there is a solution.

    Below is the Logic Builder flowchart design for the before_save logic hook that logs "account_user_c" Relate type record data

    Please note, that by logging not only the account_user_c" changes but also an ID for that relate field, you will find both ID values, previous and new, are fetched correctly.

    Therefore in the flowchart, the previous and new IDs are used to retrieve FullNames of the users to solve your task.

    here are the results in the Log:

    As you can see, the previous user ID is "seed_sally_id" and FullName is "Sally Bronsen", while the new user id is "seed_will_id" and FullName is Will Westin

    In the same time, the previous and new "account_name_c" values are incorrect, so please do not rely on them

    I hope this helps

    Best Regards,
    Dmytro Chupylka

    integroscrm.com
    We make work in Sugar CRM system faster, more convenient and efficient

Children
No Data