0

Has anybody got experience or ideas how I can resolve the following issue please?

We're trying to query attachments sent via outbound email from the email related list on case, so that we can copy the attachment data and process it.

Attachments added this way don't seem to hit triggers (as per this known issue with no fix: https://trailblazer.salesforce.com/issues_view?id=a1p300000008YTEAA2)

I tried another idea, by putting a trigger on EmailMessage and trying to query attachments where Attachment.ParentId = EmailMessage.Id, however these attachments aren't available while we're in the execution context of the emailmessage trigger... probably a timing issue

We don't want to go down the route of writing more scheduled jobs to check this, but I'm afraid we'll have to. Is this the only way to achieve this?

1

here's an idea:

  • after insert Trigger on EmailMessage executes a queueable, passing Set<Id> emailMessageIds
  • Queueable won't start until after the transaction ends, by which time the attachment is associated to its parent email message.
  • Queueable has the emailmessage.ids, can then query for the attachment(s) and do work
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.