AnsweredAssumed Answered

How can I get all status of cases via load_relationship in logic hook

Question asked by Autchara Chaiprom on Nov 9, 2016
Latest reply on Jan 26, 2017 by Autchara Chaiprom

Hi I found this in document

http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.7/Data_Framework/Models/SugarBean/#Fet… 

 

I put in to logic hook its work but it return huge result.

 

How can I get all status from this ? any suggestion ?

 

I tried to using array_filter but it return wrong result.

I need to filter status to make a decision  in my logic.

 

 

if ($bean->load_relationship('cases')){
   $relatedBeans = $bean->cases->getBeans();
   $checkCase = array_filter($bean->cases->getBeans(), function($case){
       return $case->test_c == 'x1' && $case->test2_c == 'x2' && date("Y-m-d",strtotime($case->date_entered)) == date("Y-m-d") ;
   });
   $GLOBALS['log']->fatal($relatedBeans);
}

 

Sugar 7.7

Thanks,

May

Outcomes