before_relationship_add after returning after relationship informaiton

Hi everyone.

I'm having an issue currently with before_relationship_add, what I am wanting to do is to interrogate the change to a 1:1 relationship. So for instance my idea was:

Relationship changes from A to B.

I load A and find the old name.

I load B and find the new name.

I add a note to say "Changed A to B".

However in the before_relationship_add and the after_relationship_add both seem to return B no matter what I do. I am using the "$arguments['id'] as my reference to check this.

Any ideas on this?

Thanks,

Parents
  • Per Sugar's documentation
    "One-to-One: This type of relationship is the most restrictive and results in a relate field in both modules. You can create the relationship in either the primary or related module."

    What this means is that if you are working in a record and change the related record from A to B, as soon as A is saved, the related record becomes B, because relate fields are simply Foreign Keys to the related record.

    So to see that A is about to change to B you should use a before_save logic hook. There you can see the before and after values using the bean: 

    $bean->fetched_row['your_relate_field'] // the value before the change 

    and

    $bean->your_relate_field // the value it will be once saved 

    Hope this helps,

    FrancescaS

Reply
  • Per Sugar's documentation
    "One-to-One: This type of relationship is the most restrictive and results in a relate field in both modules. You can create the relationship in either the primary or related module."

    What this means is that if you are working in a record and change the related record from A to B, as soon as A is saved, the related record becomes B, because relate fields are simply Foreign Keys to the related record.

    So to see that A is about to change to B you should use a before_save logic hook. There you can see the before and after values using the bean: 

    $bean->fetched_row['your_relate_field'] // the value before the change 

    and

    $bean->your_relate_field // the value it will be once saved 

    Hope this helps,

    FrancescaS

Children