Where do I add a trigger for "Notes and Attachments" in salesforce.com?
Asked Answered
S

4

5

I cannot find where in the salesforce.com UI I can add a trigger on a file attachment. I can find triggers on almost everything else, but attachment seems to be missing from the list (even when I view source on the page and search it. Does anyone know WHERE I can put this trigger in?

Sebastian answered 22/3, 2011 at 17:53 Comment(2)
You might be able to use the hack to create a new trigger, but how would you modify it once it's in? Seems like the only manageable path is to use the foce.com IDE :/Viscera
now you can do it using the api 29Oversight
S
6

There is no way to do it directly as Attachment is one of those "lesser" objects that salesforce really gets "protective" about in a random and biased way. The only "legit" way to do it is to use some external build&deploy tools such as Force.com IDE.

If however you are not a stranger to undocumented 'hacks' do the following. Go to any object's trigger list and click create new. In the URL locate entity query string parameter (e.g. entity=Case) and change it to Attachment (entity=Attachment) and press Enter. Newl loaded screen will accept Attachment trigger.

Swayder answered 23/3, 2011 at 10:54 Comment(2)
Hardly seems like a longtime solution, using an undocumented API they could close up at any moment.Sebastian
well, you can always go the Force.com IDE way which is documented and supported. Using small hacks from time to time is unfortunately a necessity for salesforce as their team has a very difficult way of responding to feature requests. It subjects them to vox populi on idea exchange and there only issues that affect majority of people get proper voting and issues that affect minority never see the light of day. If you were to ask for attachment trigger screen there I could bet your idea will wait forever, I have three of those, one over 3 years in waiting. Therefore, hacks.Swayder
A
3

Using Eclipse (Force.com IDE plug-in), right-click on your project & select "New" > "Apex Trigger". In the dialogue window that pops up, there is an "Object" dropdown / picklist, choose the object you want from this list - "Note" or "Attachment" etc. - then choose the "events" you want to trigger to execute on.

NOTE: a best practice is only one (1) trigger per object since you cannot guarantee the order in which multiple triggers on the same object will execute.

Ardolino answered 13/7, 2011 at 18:53 Comment(0)
A
2

Have you tried creating the trigger from, force.com IDE??

In my opinion it should be possible from there.

Attain answered 23/3, 2011 at 10:54 Comment(0)
B
0

To write a trigger for attachment, there is no straight way to do it but you can do it.

By creating a trigger on other object for example create a trigger in contact object then the url of the current page shows
"https://ap1.salesforce.com/........./&entity=Contact" you have to change "entity=Attachment"
then the trigger will be created for attachment object.

Breadth answered 22/8, 2012 at 4:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.