0

I have a custom object which is created via an online form. It is possible to add attachments and this all works fine - the object is saved and so are the attachments.

In the 'after insert' trigger on the object I call a class which sends an email out with a pdf of the content of the newly added object, which all works nicely. The problem is I also need to include the attachments that were added to this new object, but it seems they are not yet attached before the end of the trigger. I've checked the debug log and the query for the attachments returns 0. Once the trigger completes the attachments are there.

Is there any way I can run the class I call from the trigger with a delay action? I have @future in the class, but it still seems to run immediately and not pick up the attachments.

2
  • Are the Attachment records also created asynchronously?
    – Adrian Larson
    Commented Apr 26, 2016 at 4:34
  • I'm using FormAssembly to insert a new record. Along with the insert it includes the attachments (if any). I need to send an email to alert the services team that a new record has been created and attach the new record with its attachments to this email.
    – Irene
    Commented Apr 26, 2016 at 4:38

1 Answer 1

1

It seems that your service inserting record in first place, than it takes recordid from response and send attachment for this. That's why trigger for object couldn't select id.

  1. If you are adding attachment every time, you could create trigger for attachment itself
  2. Otherwise You could create timebase workflow field update for you object, and check this this value in trigger. Attachment should be available
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .