function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Michael MMichael M 

Are there any common ID's on ListEmail class and EmailStatus class?

Are there any common ID's on ListEmail and EmailStatus classes? 

My task is to get the emailstatuses of list emails sent through a campaign. I know that ListEmail class can get the CampaignID. But now I need to get the Email Statuses of those emails. Is that possible? I would be able to do it by the ownerid of the listemail or by the campaignid.  Are there any common fields between listemail and emailstatus?
Best Answer chosen by Michael M
Michael MMichael M
Thank you very much. I found an additional way to do this: when a List Email is sent from a campaign, that list email can be queried by campaignid = the campaign's id.  Also, when a list email is sent out, task records (one for each contact who was sent the email) is simultaneously created, and the whatid of that task = the id of the ListEmail. 

All Answers

AbhishekAbhishek (Salesforce Developers) 
Michael,

There are no common ids on ListEmail and EmailStatus.

For further reference check the below,

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_emailstatus.htm

https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_listemail.htm


Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Thanks.
Michael MMichael M
Hi Abhishek,

Is there any other way to connect the 2 with different queries? What about the Contact and the campaign? Or the contact and the listemail? 
Michael MMichael M
I have these:

1. campaign camp = [select id from campaign where id = '7013l000000yq77AAA'];
2. list<listemail> le = [select id, createddate, fromaddress, totalsent, ownerid from listemail where campaignid = :campid];

and I need to be able to connect those with this: 
3. List<Contact> contList = [Select id, name, CreatedDate, lastModifiedDate, email,
                           (SELECT  id, taskId, createdDate, firstOpenDate, lastOpenDate, timesOpened, emailTemplateName, task.subject, task.TaskSubtype FROM EmailStatuses where createddate = today and task.tasksubtype = 'ListEmail' )   from Contact where email != null ];
 
AbhishekAbhishek (Salesforce Developers) 
Micheal, I haven't tried this scenario yet.

But as I think it is in Beta version,

https://help.salesforce.com/articleView?id=release-notes.rn_sales_account_campaign_members.htm&release=230&type=5


Check this Idea too,

https://trailblazer.salesforce.com/ideaView?id=08730000000BrEVAA0


Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Thanks.
Michael MMichael M
Thank you very much. I found an additional way to do this: when a List Email is sent from a campaign, that list email can be queried by campaignid = the campaign's id.  Also, when a list email is sent out, task records (one for each contact who was sent the email) is simultaneously created, and the whatid of that task = the id of the ListEmail. 
This was selected as the best answer