1

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.

1
  • 1
    user5428, I've taken the liberty to remove some unnecesairy(unrelated) tags. Please try to only use tags closely related to the content of your question, that will help you attract the users with the right knowledge to your question. Posting 2 separate questions also makes it rather harder for anyone to respond, I would suggest you post the 2nd one as a separate question. Also: have you already tried something ? Other users are often more motivated to help if they see you have already made an attempt or some research yourself. Commented Apr 11, 2014 at 19:30

1 Answer 1

3

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()) 
    {
        // ...
     }
 }

You must log in to answer this question.

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