Programmatically Find the Name of the Relationship between two Modules

bsoremsugar —  May 29, 2013 — 1 Comment

Editor’s Note: This post came from Sugar Community member¬†Francesca Shiekh. Thanks Francesca!

I often find myself referencing Jeff Bickart’s “HOWTO: Using the bean instead of SQL all the time.” (http://developers.sugarcrm.com/wordpress/2012/03/23/howto-using-the-bean-instead-of-sql-all-the-time/ )

But when it comes to using the tips in “Adding and removing related records” finding the right relationship name is always a challenge (it is NOT the relationship_name field in the relationship table!).

Also, I sometimes need to find that relationship name programmatically based on module names.

To address this problem I created the following function which, given two module names, returns the name of the relationship needed to load, add and delete relationships between records. If there is no relationship between the modules the function returns FALSE.

One response to Programmatically Find the Name of the Relationship between two Modules

  1. 

    Nice
    Thanks John

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s