AnsweredAssumed Answered

How to find the relationship name between two custom modules?

Question asked by jlabuelo on Dec 12, 2014
Latest reply on Jul 6, 2015 by jclark@enhanced.co.uk
Hi there

I have created two custom modules with a one to one relationship

R2_Microchip has a one to one relathichip with R2_Solicitud. I am builing a button in the DetailView of the R2_Solicitud module and this button calls a controller function that needs to take the related R2_Microchip and work with it.

To do so i need to know the relationship between these two modules to be able to call it.

I have found in this forum a post that points to  this blog

http://developer.sugarcrm.com/2013/05/29/programmatically-find-the-name-of-the-relationship-between-...

However in my code, when I call this function this way

$rel_microchip = getRelationshipByModulesgetRelacion("R2_Solicitud","R2_Microchip");

  $bean_solicitud->load_relationship($rel_microchip);
  $chip_bean=implode($bean_solicitud->$rel_microchip->get());

I get this error message in the log file
Warning: Illegal offset type in isset or empty in /opt/lampp/htdocs/sugarcrm/data/SugarBean.php on line 975

Notice: Array to string conversion in /opt/lampp/htdocs/sugarcrm/custom/modules/R2_Solicitud/Funciones_Solicitud.php on line 75

Notice: Undefined property: R2_Solicitud::$Array in /opt/lampp/htdocs/sugarcrm/custom/modules/R2_Solicitud/Funciones_Solicitud.php on line 75

Fatal error: Call to a member function get() on a non-object in /opt/lampp/htdocs/sugarcrm/custom/modules/R2_Solicitud/Funciones_Solicitud.php on line 75
(Line 75 is this one in my code $chip_bean=implode($bean_solicitud->$rel_microchip->get());)

As the function is returning just the word "Array".
If this function does not work.... How can I know how to call the relationships between two custom modules like 
$bean_solicitud->load_relationship($rel_microchip);??????

Thanks a lot!!

Outcomes