Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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.

share|improve this question
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. –  Samuel De Rycke Apr 11 at 19:30

1 Answer 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()) 
    {
        // ...
     }
 }
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.