$bean->stored_fetched_row_c, logic hooks and relate fields

Im trying to detect a change in a relationship through a logic hook but I cant seem to get the old value to compare it to the new.

I have a serial number module which has a relationship to accounts

Accounts -> one-to-many -> S_SerialNumber

this is visible in my module view and i can get the relationship data if i query the S_SerialNumber

    "accounts_s_serialnumber_1_name": "ID Print",
    "accounts_s_serialnumber_1": {
        "name": "ID Print",
        "id": "cac71e64-7c2c-11eb-9bf6-066c2def7d44",
        "_acl": {
            "fields": {
                "business_center_name": {
                    "create": "no",
                    "write": "no",
                    "license": "no"
                },
                "business_center_id": {
                    "create": "no",
                    "write": "no",
                    "license": "no"
                }
            },
            "_hash": "e376f7492abb281a71d6a0860441877a"
        }
    },
    "accounts_s_serialnumber_1accounts_ida": "cac71e64-7c2c-11eb-9bf6-066c2def7d44",

the problem I'm having is I want to detect if this relationship is changed on an after_save logic hook

My before_save hook captures the data with the 

        public function get_record($bean, $event, $arguments)
        {
            $bean->stored_fetched_row_c = $bean->fetched_row;
        }

However $bean->fetched_row does not include the relationship data for me to then compare

If I use the $bean->load_relationship() it only gets the updated data

Anybody know how you compare a relationship between a before and after save logic hook?

Parents
  • Hello John,

    As I can see, this logic hook is easily configurable with the Logic Builder co-code tool and the subscriber's Sugar Admin with no coding skills could make it.

    Here is the example - on S_SerialNumber record is assigned to another Account, do read previous and new Account names, then concatenate them and put into Description:



    The drawing for this behavior is fairly simple (follow the white line to read):



    And zip to install with ModuleLoader is got in a click:
    BothAccPreviousAndAccNew.zip

    Let me know if any questions

    Best Regards,
    Dmytro Chupylka

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

Reply
  • Hello John,

    As I can see, this logic hook is easily configurable with the Logic Builder co-code tool and the subscriber's Sugar Admin with no coding skills could make it.

    Here is the example - on S_SerialNumber record is assigned to another Account, do read previous and new Account names, then concatenate them and put into Description:



    The drawing for this behavior is fairly simple (follow the white line to read):



    And zip to install with ModuleLoader is got in a click:
    BothAccPreviousAndAccNew.zip

    Let me know if any questions

    Best Regards,
    Dmytro Chupylka

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

Children