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
ShrutikaShrutika 

Hey everyone , facing issue with contentdocumentLink(CDL) object.

have already written trigger on CDL object.

Whenever I am submitting service request with multiple attachment , 
trigger first should handle all attachment at once of that record and then must call apex method (send email) is the scenario.

At this time , for every attachment it is calling apex method and sending separate email.

Even If multiple attahment are attached to record , it sends separate email for every attachment.

(Note - can't write trigger on incident obj , as  after inser attachment is not getting available.)

Your help would be much appreciated.
sfdcBahusfdcBahu
I dont think you can achieve it straight, since salesforce handles each file has separate transaction insert (may be to control the heap size) in the multi file upload window.

IF the purpose of the Email is just to notify a user that Attachments are added, then from your CDL record set a flag on the LinkedEnity i.e Incident record. Then fire your email logic from the Incident trigger when the first time the Flag is set from false to True.

Or if you wanna notify about total number of attachments attached to the Incident, then i would use the similar logic to set a flag on the Parent record. Then fire a scheduled action in your Process builder to run the logic after 2 minutes from the time the Flag is checked.

So when the first attachment is uploaded, the system would set the flag.
Then PRocess builder will be fired once for the First attachment.
2 minutes later the Action will be called, at that time count or fetch all the attachments added and send email
.