Can I detect when an attachment is related to an account from a Trigger on account ??
Also, I want the trigger to post to chatter that the attachment has been uploaded upon completion.
Attribution to: user5428
Possible Suggestion/Solution #1
You will need to use a trigger on Attachment
for this.
You can create a trigger on Attachment
using the Developer console, or the Force.com IDE (as well as MavensMate), but NOT using the Setup menu like you would with any other object (unless you do a bit of URL hacking).
Edit (appending Keith C's answer so there is one complete answer rather than two partial ones):
Then to check that it is an Attachment of an Account and not some other object:
for (Attachment a : Trigger.new)
{
if (a.ParentId.getSObjectType() == Account.getSObjectType())
{
// ...
}
}
Attribution to: Alex Tennant
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/32560