You need to sign in to do that
Don't have an account?
Dr. Thomas Miller
Delete tasks related to EMailMessages
If I create an EMailMessage record via SOAP API, the SF system automatically creates an associated task record which is shown in the activity history or open activities related list.
Now, if I did something wrong and delete the EMailMessage record (as I cannot update it) the task record is left.
It can be deleted from the related list UI but doesn't show up in a SOQL query nor in a Data Loader export.
Is there any programmatic way to get rid of these task records?
Now, if I did something wrong and delete the EMailMessage record (as I cannot update it) the task record is left.
It can be deleted from the related list UI but doesn't show up in a SOQL query nor in a Data Loader export.
Is there any programmatic way to get rid of these task records?
These tasks have the subtype "Email" and the field ACTIVITYID has the ID of the task in EMAILMESSAGE.
Apex/SOQL : SELECT count(id) FROM Task WHERE tasksubtype = 'Email' ( and ISARCHIVED = true and ISDELETED = true ALL ROWS )
Apex: DELETE [ SELECT ID FROM EMAILMESSAGE WHERE ACTIVITYID = '00T0Y00000DtrdmUAB' ];
The deletion of the Emailmessage delete also the associated task ( ACTIVITYID is filled in Emailmessage ).
Other tests:
https://help.salesforce.com/articleView?id=000199524&type=1
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_guidelines_archive.htm
What is the result when you search via the "Mass Delete" (setup : Data Management > Mass Delete Records > Activities )
with the criteria "Activity Subtype" equals "Email" ?
Best regards
Alain