Newer Version Available
CampaignMember
Supported Calls
For API version 15.0 and earlier: create(), delete(), describeLayout(), describeSObjects(), getDeleted(), getUpdated(), query(), retrieve(), update(), upsert()
For API version 16.0 and later: upsert()
Fields
Usage
Each record has a unique ID, and must contain either a ContactId or a LeadId, but can't contain both. Any attempt to create a single record with both results in a successful insert but only the ContactId is inserted. However, you can create two separate records on a Campaign—one for the Lead and one for the Contact.
1SELECT Id, (SELECT Phone FROM Lead)
2FROM CampaignMemberThis object is defined only for those organizations that have the marketing feature and valid marketing licenses. If the organization does not have the marketing feature or valid marketing licenses, this object does not appear in the describeGlobal() call, and you can't use describeSObjects() or query() with the CampaignMember object.
In API version 16.0 and later, a create() call only creates record; in earlier versions, a create() call creates and updates records. The API determines whether a record exists with the specified CampaignId and either ContactId or LeadId.
When using the API, the create() call only requires read access to campaigns.
If the record does not exist for the given ContactId or LeadId, then a new record is created. If the record exists, an error is returned and no update is made. To update an existing record, specify the ID of the CampaignMember record to update.
In API versions 15.0 and earlier, if you submit multiple records using a single create request, and if more than one record matches an existing record, only the first record submitted updates the existing record. If any of the submitted records match each other but do not match existing records, only the last record submitted is created.
The upsert() call is not supported in API version 16.0 and later. To use the upsert() call on this object, you must first delete all data in ID fields except the record ID.
To delete a record, specify the ID of the CampaignMember record to delete.
When creating or updating records, the Status field value specified in the call is verified as a valid status for the given Campaign:
- If the specified Status value is a valid status, the value is updated, and the HasResponded field is updated to either true or false, depending on the Status value association with HasResponded.
- If the specified Status value is not a valid status, the API assigns the default status to the Status field and updates the HasResponded field with the associated value. However, if the given Campaign does not have a default status, the API assigns the value specified in the call to the Status field, and the HasResponded field is set to false.