1

I want to add multiple email address to a contact via SOAP api, suppose i register a user from my php app. via registration page with testemail1@test.com for ex., so this will create a new contact in sugarcrm via set entry and "email1" parameter in soap set_entry call, in name_to_value_list array.

Now suppose i update the account information in my php web app. and updates email address to testemail2@test.com , so now, this should add this new email address to the current contact as primary email address and opt out the old email address (as we can add multiple email address to sing contact record).

see the sample code here :

    $result = $mySoap->call('set_entry', array($session_id, 'module_name'=>'Contacts',     array(
    array("name" => 'first_name',"value" => $_POST['first_name']),
    array("name" => 'last_name',"value" => $_POST['last_name']),
    array("name" => 'email1',"value" => $_POST['email_address']),   //Emails is suppose     testemail1@test.com for first time
    array("name" => 'primary_phone_c',"value" => $primary_phone),
    array("name" => 'prefered_contact_c',"value" => $_POST['prefered_contact']),
    array("name" => 'primary_address_street',"value" => $_POST['address']),
    array("name" => 'primary_address_street_2_c',"value" => $_POST['address_2']),
    array("name" => 'primary_address_city',"value" => $_POST['address_city']),
    array("name" => 'primary_address_state',"value" => $_POST['address_state']),
    array("name" => 'primary_address_postalcode',"value" =>     $_POST['address_postalcode']),
    array("name" => 'address_country_c',"value" => $_POST['address_country']),
     )));

So any sample Soap call or any idea like i use email2 field instead email1 in set_entry or else?

Thanks, Dhaval Darji

  • I don't think you can set an email directly in the contact. You need to manually insert a new email address in the EmailAddress module and create a relation between that email address and your user in the email_adr_bean_rel table. [see this](http://stackoverflow.com/questions/13126133/adding-contacts-to-sugarcrm-via-rest-how-to-add-email) – ychaouche Nov 20 '12 at 14:16
  • Did you solve this ? I have same plroblem. – Ronak Patel Dec 02 '15 at 10:01
  • Hi Ronak, Yes, i had fixed it and posted on sugar forum, but unfortunately its not available now! Still http://developer.sugarcrm.com/2012/09/25/adding-multiple-emailaddresses-via-web-services/ this should work for SOAP as well, ultimately you have to make set entry call to email addresses module and then link it back to contact module instead of setting email1 and email2 fields. – Dhaval Darji Dec 03 '15 at 11:18

0 Answers0