Skip to content

sendEmail doesn't support multiple toAddresses #14

Open

Description

@ellieayla

http://www.salesforce.com/developer/docs/api/Content/sforce_api_calls_sendemail.htm states that several fields, including toAddresses, accept arrays of values. in SOAP XML, this translates to multiple <p:toAddresses /> elements.

In pyforce.py _doPrep, there exists a joining of list items, which results in multiple items concatenated in a single element instead of multiple elements.

      else:
            field_dict[k] = ";".join(v)

Activity

  1. ellieayla commented on Nov 22, 2014

    @ellieayla
    ContributorAuthor

    If this was a no-op or as follows, the generated SOAP XML request would have multiple <p:toAddresses /> elements.

         else:
                field_dict[k] = v
    

    However, I do not know whether that would break anything else. Presumably this implementation is as-is for a reason. Maybe _prepareSObjects should be special-cased for sendEmail.

  2. idbentley commented on Nov 24, 2014

    @idbentley

    Yes, at least in some cases the sfdc api correctly parses ; delimited strings into arrays of strings. I haven't tested it with emails, and I assume you are bringing this forward because you have tested it?

    I can't find the documentation about string array parsing, but I find it odd that it would be inconsistent. Can you try and find the related doucmentation?

  3. ellieayla commented on Nov 25, 2014

    @ellieayla
    ContributorAuthor

    Yes, I have tested it with with a list like ToAddresses = ["[email protected]", "[email protected]"], and with that one-line hack above. A modification to the post function to dump xml payload makes the mismatch apparent.

  4. ellieayla commented on Nov 25, 2014

    @ellieayla
    ContributorAuthor

    It seems like this semicolon behavior is specific to multi-value picklist fields. http://www.salesforce.com/developer/docs/api/Content/field_types.htm#i1435691 says

    Multi-select picklist fields contain a list of one or more items from which a user can choose multiple items. One of the items can be configured as the default item. Selections are maintained as a string containing a series of attributes delimited by semicolons. For example, a query might return the values of a multivalue picklist as “first value; second value; third value”. For information on querying multi-select picklists, see Querying Multi-Select Picklists in the Salesforce SOQL and SOSL Reference Guide.

    See also;

    1. https://success.salesforce.com/answers?id=90630000000giKLAAY
    2. http://salesforce.stackexchange.com/questions/10887/pulling-picklist-options-from-a-multi-value-field
    3. http://www.salesforce.com/us/developer/docs/officetoolkit/Content/sforce_api_calls_soql_querying_multiselect_picklists.htm
  5. ellieayla commented on Nov 25, 2014

    @ellieayla
    ContributorAuthor

    This behavior mirrors multiMarshaller in marshal.py. Looks like it's been around for a while.

  6. ellieayla commented on Dec 3, 2014

    @ellieayla
    ContributorAuthor

    Note that this only affects pyforce.Client. xmlclient.Client doesn't do any marshaling of outbound lists so the list of addresses goes through intact.

  7. idbentley commented on Feb 5, 2015

    @idbentley

    This is a little bit annoying, and requires handling ; as a special case.

  8. ellieayla commented on Feb 7, 2015

    @ellieayla
    ContributorAuthor

    I deferred the decision for how that special handling should be done and just documented the problem. If you feel strongly about a particular solution please propose it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions