
If you are using native Salesforce user interface, then you can go to Create-->Objects, and select your object. Go to the Triggers section, and click on New to start a new trigger on this object. To write a trigger on Attachment you have to use Eclipse.
- Click on your name at (top left corner) and Select “Developer Console”
- Go to File -> New -> Apex Trigger.
- Select name of SObject and enter name of trigger.
- Click on submit button. In this way we can create trigger on attachment.
How to create trigger on attachment in Salesforce apex?
Here are steps to create trigger on attachment using developer console. 1. Click on your name at (top left corner) and Select “Developer Console” 2. Go to File -> New -> Apex Trigger. 3. Select name of SObject and enter name of trigger 4. Click on submit button. In this way we can create trigger on attachment.
How to write a trigger for attachment object?
To write a trigger for attachment, there is no straight way to do it but you can do it. then the trigger will be created for attachment object. Thanks for contributing an answer to Stack Overflow!
How to create a trigger in Salesforce user interface?
For the Attachment, ContentDocument and Note standard objects, we can’t create a trigger in the Salesforce user interface. For these objects, we can create a trigger using development tools, such as the Developer Console or the Force.com IDE.

Can we write a trigger on notes and attachment in Salesforce?
Standard Salesforce functionality does not allow any modification to Note and Attachment object. The trigger can also be created/written using Force.com IDE or ANT. Note: We cannot write a trigger on "Attachment" object using the Salesforce.com UI rather we have to use Developer console or VS Code.
Can we write trigger on custom object in Salesforce?
Apex triggers enable you to perform custom actions before or after changes to the Salesforce records, such as insertions, updates, or deletions. The trigger code is stored as metadata under the custom object. window appears. Enter a name for the trigger.
How do I add an attachment to a Salesforce object?
To navigate to 'Attach File' in Salesforce ClassicGo to any task or events records (either via home tab or via open activities/activity history related list of any record).Click Edit.Scroll down to Attachments related lists, then click Attach File.
How do I write a trigger email in Salesforce?
Step 1: Create a Trigger that Sends Confirmation EmailsIn the Developer Console, click File > New > Apex Trigger.Specify SendConfirmationEmail as the trigger name, Session_Speaker__c as the sObject, and click Submit.Implement the trigger as follows: ... Save the file. ... Test the trigger.
Can we write trigger on share object?
Unfortunately, this is not possible, as share records do not cause triggers to fire. You will need to come up with an alternative solution, such as using criteria-based sharing rules or some other mechanism. Show activity on this post. Yes you are right, one cannot have Trigger on Share Object.
Can we update same object in before trigger?
It's possible in a before trigger, but not recommended. The benefit of using a before trigger is that you're able to make updates to the records being triggered (i.e. the instances of the records in trigger. new or trigger.
How do I add an attachment to Salesforce lightning?
In Lightning Experience Click Add Files in the Files related list menu, or drag files directly onto the Files related list. (You can drag multiple files, but not a folder. You can't drag files onto read-only related lists.) Note In Lightning Experience, your org may use a custom page layout for the file detail page.
What object are attachments stored in in Salesforce?
Files attached to emails and events can be saved in Salesforce as Content documents (Files) or as Attachment objects, the former being the default way. In either case the files are stored in Salesforce under Notes & Attachments of the primary associated object(s).
How do I find the attachment object in Salesforce?
To see all attachments on a record, ensure that the Notes & Attachments related list is added to each of your page layouts. To do this, click on Setup, open the Object Manager and select the Object you'll be using.
Can we send email through trigger?
You need to create an apex trigger on contact object which send email when contact will inserted. List
How do I send an apex email alert?
0:4715:2612 | Send Email Notification through Apex Trigger - YouTubeYouTubeStart of suggested clipEnd of suggested clipSo upon creation of contact record a welcome email notification should be triggered to the email idMoreSo upon creation of contact record a welcome email notification should be triggered to the email id populated on contact record through apex trigger.
How do I send an email to Apex in Salesforce?
The syntax for sending an email is: Messaging. sendEmail(new Messaging....Note the following:The email is not sent until the Apex transaction is committed.The email address of the user calling the sendEmail method is inserted in the From Address field of the email header. ... Maximum of 10 sendEmail methods per transaction.More items...
Archit
I have to write a Salesforce trigger for custom Object 's Attachments.
Archit
Actually, I am not able to find out whether I can write trigger on attachment or not. Please help me out.
PRANAV
To write a trigger on Attachment you have to use Eclipse. Open your Org in Eclipse then create a new trigger where you will get a picklist to select the Attachment Object. This is the only the way to write a trigger on Attachment. Below is the sample code of the trigger :
Manpreet
I think we should also add an event of after update as well in trigger because sometimes attachments can also be changed as per requirements. I think we should also focus on same.
