AnsweredAssumed Answered

How to avoid chasing red herrings in logic hook relations?

Question asked by Josh Wright on Dec 27, 2018
Latest reply on Dec 27, 2018 by Josh Wright

Hello all,

 

I am a web developer who is learning sugarcrm at my new workplace. I have a fair understanding of the MVC workflow as well as SQL and programming. My question is as follows: How do you determine the correct relationship to use with the SugarCRM Bean data framework?

 

For example: let's say I want to link prospect lists to Contacts by logic hook. My first thought is to go into the Studio and look for the relation between prospect lists(target lists) and Contacts. I see a relation between contacts and target lists called "prospect_list_contacts" and get to work setting up my logic hook and loading relations. Some troubleshooting later, I realize this is a red herring relationship and the real relationship is actually loading the Contacts relationship itself. such as: $targetlist->load_relationship('contacts'); However, this method seems to work with some relationships(notably ones that aren't built into sugar).

 

If I want to go even further, the relationship within SQL is prospect_lists_prospects WHERE related.type = "Contacts" if I wanted to find the related ID's to a target/prospect list, adding even more to the confusion. Is there an easier way of testing and finding the correct relations?

Outcomes