I have a custom endpoint. Its aim is to retrieve a bean from the Opportunities module to generate a pdf. On the first place, I coded it as a custom entrypoint and it worked fine, but as its behaviiour can be unexpected due to the following bug (https://web.sugarcrm.com/support/issues/73434) and entrypoints are being deprecated, I decided to move it to a custom endpoint.
The issue in the endpoint comes when I tried to retrieve related beans (accounts, createdby (users)). The code I have is the following:
$bean = BeanFactory::retrieveBean('Opportunities',$GLOBALS['opID'], array('disable_row_level_security' => true));
$relatedBeans = array_pop($bean->accounts->getBeans());
$email = $relatedBeans->emailAddress->getPrimaryAddress($relatedBeans);
I need to disable security as I have set on the endpoint definition "'noLoginRequired' => true".
The function load_relationship is not loading anything, therefore, when I tried to access to the primary email, I get the following error:
Call to a member function getPrimaryAddress() on a non-object
I think something else is necessary to bypass security when loading relationships, as this code works fine as an entrypoint (authentication was set to true, then I didn't need to bypass it).
I have tried to pass the " array('disable_row_level_security' => true)" parameter to the load_relationship method but I still get the same error.
Any ideas how can I load the related beans?