2011-12-21 126 views
0

我面臨一個Sugar 6.3 CE安裝,試圖通過休息api創建新帳戶。在創建休息api帳戶時插入電子郵件

我仍然處於很多CRM內部的學習曲線,並且無法弄清楚如何通過REST調用創建帳戶信息的其餘部分時插入電子郵件。

我已經嘗試了許多不同的字段值,並且在獲取$email1之後,我在SugarCRM網站上看到了一些片段示例。我還沒有在論壇或文檔中發現其他提及。

用於配置一般的REST調用創建具有REST API在PHP的帳戶$參數數組看起來像這樣和正常工作,除了爲$ EMAIL1:

$parameters = array(
'session' => $session, 
'module' => 'Contacts', 
'name_value_list' => array(

    array('name' => 'first_name', 'value' => 
    utf8_encode($contacts["Name"])), 

    array('name' => 'last_name', 'value' => 
    utf8_encode($contacts["GivenName"])), 
    array('name' => 'phone_work', 'value' => 
    utf8_encode($row->PrimaryPhoneAreaCode . ' ' . $row->PrimaryPhone)), 

    array('name' => 'phone_fax', 'value' => 
    utf8_encode($row->PrimaryFaxAreaCode . ' ' . $row->PrimaryFaxNumber)), 
    array('name' => 'title', 'value' => 
    utf8_encode($contacts["Title"])), 

    /* 
    * PROBLEM HERE! 
    */ 
    array('name' => 'email1',  'value' => 
    utf8_encode($row->PrimaryEmail)), 

    array('name' => 'primary_address_street', 'value' => 
    utf8_encode($row->Address1) . ' ' . 
    utf8_encode($row->Address2)), 
    array('name' => 'language', 'value' => 
    utf8_encode($row->Language)), 

    array('name' => 'assigned_user_id', 'value' => 
    get_rep_id($row->Salesperson1Name, $sugarlink)), 
    ) 
); 

我會好奇,如果有人有竅門。我試圖找到電子郵件領域,但它似乎在單獨的表。任何幫助/提示表示讚賞。

回答

1

您必須添加到電子郵件數據庫的emailadress首先,創建聯繫人,並設置兩個;-)

$set_entry_parametersEADDR = array(
      "session" => $session_id, 
      //The name of the module from which to retrieve records. 
      "module_name" => "EmailAddresses", 
      //Record attributes 
      "name_value_list" => array(
      array('name' => 'email_address', 'value' => $email), 
      array('name' => 'email_address_caps', 'value' => strtoupper($email)), 
      array('name' => 'invalid_email' , 'value' => 0), 
      array('name' => 'opt_out', 'value' => 0), 
      array('name' => 'date_created' , 'value' => date('Y-m-d H:i:s')), 
      array('name' => 'date_modified', 'value' => date('Y-m-d H:i:s')), 
      array('name' => 'deleted' , 'value' => 0), 
      ), 
     ); 

     $set_entry_resultEmailsAdd = call("set_entry", $set_entry_parametersEADDR, $url); 
     print_r($set_entry_resultEmailsAdd); 
     $Email_id = $set_entry_resultEmailsAdd->id; 

     $set_entry_parameters_contact = array(
       //session id 
       "session" => $session_id, 

       //The name of the module from which to retrieve records. 
       "module_name" => "Contacts", 

       //Record attributes 
       "name_value_list" => array(
        //to update a record, you will nee to pass in a record id as commented below 
        //array("name" => "id", "value" => "9b170af9-3080-e22b-fbc1-4fea74def88f"), 
        array("name" => "first_name", "value" => $prof["Prenom"]), 
        array("name" => "last_name", "value" => $prof["Nom"]), 
        array("name" => "login_c", "value" => $prof["Login"]), 
        //array("name" => "email1", "value" => $email), 
        array("name" => "fonction_c", "value" => "prof") 
        ), 
       ); 

     $set_entry_result_contact = call("set_entry", $set_entry_parameters_contact, $url);  
     print_r($set_entry_result_contact); 
     $contact_id = $set_entry_result_contact->id; 

     $set_relationship_parameters_email = array(
      'session' => $session_id, 
      'module_name' => 'Contacts', 
      'module_id' => $contact_id, 
      'link_field_name' => 'email_addresses', 
      'related_ids' => $Email_id, 
     ); 

     $set_relationship_result_email = call("set_relationship", $set_relationship_parameters_email, $url); 
     print_r($set_relationship_result_email); 
+0

之間的關係呀。我們走了!代碼並不是那麼漂亮,但它看起來像它在錫上所說的那樣。請不要等下6年; o) – stefgosselin 2017-04-25 03:05:37

1

目前我認爲這不適用於REST api,但適用於SOAP API。您可以嘗試使用email1_set_in_workflow密鑰而不是email1? 這不是一個很好的解決方案,但或許有助於解開你一個更好的方式來做到這一點在未來的版本中

2

如果使用REST API的EMAIL1將工作兩個設置連接得到方法(待定剛剛測試過)。

未按照您的示例使用SOAP API,並建議根據SugarCRM建議將所有內容遷移到REST。

相關問題