2014-01-06 63 views
1

我正在使用SugarCRM API,我需要創建一個Case,然後將其Relate它創建爲Contact記錄。我已經嘗試了很多下面的code3的組合,並不斷得到一個結論,說沒有爲我的關係創建記錄。SugarCRM通過API將案例關聯到聯繫人記錄?

我終於改變了它,我現在得到的結果是說創建了一條記錄。問題是當我在SugarCRM或聯繫人記錄中查看Case時,它們都不會在每個其他子面板中顯示,就好像關係未創建一樣!

我也是用從這裏https://github.com/asakusuma/SugarCRM-REST-API-Wrapper-Class/

我的代碼的REST API包裝到相關案例的聯繫...

$module_name = 'Cases'; 
$module_id = $caseID; 
$link_field_name = 'contacts'; // Also tried 'contacts_cases' which Fails in the result 
$related_ids = array('741c9e89-7f45-62e1-9490-524b21a6ea4f');//John Doe contact record 


$results = $sugar->set_relationship($module_name, $module_id, $link_field_name, $related_ids); 

echo '<pre>'; 
print_r($results); 
echo '</pre>'; 

從這個輸出是...

Array 
(
    [created] => 1 
    [failed] => 0 
    [deleted] => 0 
) 

所以你可以從我的輸出中看到記錄是相關的,但是當查看SugarCRM中的記錄時,我無法在模塊記錄上看到關係。任何想法可能會在這裏出錯?

回答

1

我明白了。我張貼這個,所以如果有人遇到這個問題。

$related_ids = array('741c9e89-7f45-62e1-9490-524b21a6ea4f');//contact ID 

需要是這樣......

$related_ids = '741c9e89-7f45-62e1-9490-524b21a6ea4f';//contact ID 

沒有array()因爲我使用的包裝類,增加了set_relationship()方法已經內部數組!