Adding multiple EmailAddresses via Web Services

sugarcrmdevelopers —  September 25, 2012 — 6 Comments

Came across this post on the forums recently…


I am trying to add multiple email addresses in contacts module using web services.
Its working upto three email addresses after that 4th one is not added but its updating third one only.
I am using following code in a loop

‘session’ => $result[‘id’],
‘module_name’ => ‘Contacts’,
‘name_value_list’ => Array(
array(‘name’ => ‘id’, ‘value’ => $crmid),
array(‘name’ => ’email’.$ind1, ‘value’ => $email[’email’]),

Please any body give me some idea , why more than three emails are not added.

This is one of the more tricky parts of our web services, since on the data side emails are stored indepedently of the actual records in another related table. Because of this, if you need to add more than two email addresses for a record, you need to add all the additional email addresses directly to the EmailAddresses module and then do a relationship between them. See the below code snippet for a guide on how…

Please note this only works in Sugar 6.1.2 and later, as a bug was fixed in that release in regards to the creating of new EmailAddress record directly from web services.

6 responses to Adding multiple EmailAddresses via Web Services


    hi john,

    it may be irrelevant here but i am facing issue and unable to fix it.

    i am archiving email from rest call. after successfull insertion in emails module i m creating relationship with contact module. relationship created successfully. but when i view this record in history subpanel of contacts and click this email to view detail. in detail view it is showing from and to address but in editview these addresses gone.

    i am sending these params while archiving

    var params = {
    session: session_id,
    module_name: “Emails”,
    name_value_list: {
    description_html: message,
    status: “archived”,
    type: “archived”,
    name: email_subject,
    from_addr_name: email_from,
    reply_to_addr: email_from,
    to_addrs_names: email_to,
    date_sent: date

    am i doing wrong ???
    any help will be appreciated .

    thanks in advance

Trackbacks and Pingbacks:

  1. mass removal of invalid email addresses - October 24, 2012

    […] […]

  2. Implementing set_relationships REST API - December 12, 2012

    […] […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s