2017-04-06 104 views
1

這是m邏輯掛鉤After Save,這個邏輯掛鉤在我的本地機器上完美工作。
但它不適用於sandboxcopy。我向Sugar Support團隊詢問了這個問題,他們發現Set_relationship不起作用。
但我的問題是爲什麼這是在本地工作或是否有任何替代方法來編寫此代碼,我錯了?Set Relationship is not working on sandbox Sugarcrm

class RHLogicHook { 

    function ReportingTeam($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); 

     } 
    } 

} 

請幫幫我。

回答

0

請不要在上面使用。使用負載關係和添加方法。

class RHLogicHook { 

    function ReportingTeam($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(); 

      $GLOBALS['log']->log('zob_ms_bean ' . print_r($reporting_head, 1)); 


      if ($reporting_head->load_relationship('contacts_rh_reporing_team_1')) { 
       $reporting_head->contacts_rh_reporing_team_1->add($reporting_team->id); 
      } 
     } 
    } 

} 
+0

這個答案是不正確的,我正在完美地工作。 –

0

一些功能被列入黑名單,如果多數民衆贊成的情況下,你可以很容易地使用一個技巧,以確保您的代碼下面提及招生產instance.Try的偉大工程:

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

讓我們希望這可以解決您的問題。