Set Relationship is not working on sandbox Sugarcrm

This is m logic hook After Save , this logic hook is perfectly working on my local machine.
But it is not working on sandboxcopy. I asked this question to Sugar Support team ,
They found that Set_relationship is not working .
But my question is why this is working on local or is there any alternate way to write this code, where i am wrong ?

classRHLogicHook{functionReportingTeam($bean,$event, $arguments){

   if(isset($arguments['isUpdate'])&& $arguments['isUpdate']==false){ 

        $reporting_head =BeanFactory::retrieveBean('Contacts', $bean->contact_id_c);          

       $contact =BeanFactory::retrieveBean('Contacts', $bean->contacts_rh_reporting_head_1contacts_ida);     

       $reporting_team =new RH_reporing_team();   

        $reporting_team->contact_id_c = $contact->id;     

       $reporting_team->save();     

       $dataset = array('contacts_rh_reporing_team_1contacts_ida'=> $reporting_head->id,'contacts_rh_reporing_team_1rh_reporing_team_idb'=> $reporting_team->id,);  

          $reporting_team->set_relationship('contacts_rh_reporing_team_1_c', array(),false,false, $dataset);

}

}

}

Parents
  • Hi Jagdish,

    I suspect PHP version in your local and on demand would be different.Maybe because of this it is not working in On Demand.

    Below is snippet of code that will link the records.I hope this would help you.

    $accountBean=BeanFactory::getBean('Accounts',$accountID);
    $accountBean->load_relationship('accounts_calls_1');
    $accountBean->accounts_calls_1->add($callIDs);

    accounts_calls_1 -  is relationship name between accounts and calls.

    $callIDs- It is array of call id's.

Reply
  • Hi Jagdish,

    I suspect PHP version in your local and on demand would be different.Maybe because of this it is not working in On Demand.

    Below is snippet of code that will link the records.I hope this would help you.

    $accountBean=BeanFactory::getBean('Accounts',$accountID);
    $accountBean->load_relationship('accounts_calls_1');
    $accountBean->accounts_calls_1->add($callIDs);

    accounts_calls_1 -  is relationship name between accounts and calls.

    $callIDs- It is array of call id's.

Children
No Data