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.

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

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

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

  • 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.

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

  • if you have access to studio, check on relationships the links names there as well. 

    Rodrigo Manara

    Sr. Developer