Try to fetch related/linked Contracts - but result is always empty - why?

I try to get the contracts of an Opportunity. The Contract is seen and listed in the subpanel.

If i try to load related Contracts, i always get only an empty array.

/** @var Opportunity $quote */
$opp = \BeanFactory::getBean('Opportunities', $opportunitiesId);
$opp->load_relationship('contracts');
$contracts = $opp->contracts->get();

Any ideas what i am doing wrong? Working with Sugar 10.

Also tried "getBeans()" or similar functions. Result always empty Array :-( 

Parents
  • The code seems OK.

    Make sure such an Opportunity has related Contracts through link 'contracts'. Eventually a new custom relationship has been created between those modules and populated accordingly, making built in relationshp obsolet.

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • André, you are awesome. That´s the point. It´s a "custom" Contract Modul. Haven´t thought on this (was not me). No it works. Just for reference the updated code which works now as expected.

    Thank you.

    /** @var Opportunity $quote */
    $opp = \BeanFactory::getBean('Opportunities', $opportunitiesId);
    $opp->load_relationship('opportunities_contracts_1');
    $contracts = $opp->{"opportunities_contracts_1"}->getBeans();

Reply
  • André, you are awesome. That´s the point. It´s a "custom" Contract Modul. Haven´t thought on this (was not me). No it works. Just for reference the updated code which works now as expected.

    Thank you.

    /** @var Opportunity $quote */
    $opp = \BeanFactory::getBean('Opportunities', $opportunitiesId);
    $opp->load_relationship('opportunities_contracts_1');
    $contracts = $opp->{"opportunities_contracts_1"}->getBeans();

Children