2011-12-21 54 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。

相关问题