You need to sign in to do that
Don't have an account?

Trigger Email alert when a new attachment is added to an Opportunity
Hi,
Colleagues are required to add attachments to Opportunities that they do not own, however there is no possible way using standard salesforce functionality to send an email alert to the Opportunity owner.
Does anyone know how I can achieve this using triggers?
Your help would be much appreciated! Thanks...
then make a workflow to look for changes to the review needed field. In the workflow rule, send the email and set the review needed flag back to false.
Thanks for your response ehartye.
I am not very familiar with triggers etc and I am receiving the below Compile Error message:
Error: Compile Error: Method does not exist or incorrect signature: trigger.keyset() at line 6 column 96
Any ideas? Thanks in advance...
aaah my bad :)
you want to use: trigger.NewMap.keySet()
Thanks ehartye. I have used the below Apex Trigger and this is active, but does not seem to be firing and updating the review_needed field?
Anyone got any ideas? Thanks...
You should be running the trigger on Attachment, not opportunity. Sorry for the delayed response.
Unfortunately I get the below error message:
Error: Compile Error: Incorrect SObject type: Attachment should be Opportunity at line 1 column 1
Thanks
You can't just rename the trigger and save. You have to delete it and create a whole new trigger.
I have created a new trigger but still receive the error message..
Error: Compile Error: Incorrect SObject type: Attachment should be Opportunity at line 1 column 1
The only reason you would get that error is if you were trying to change the SObject target of an existing trigger. You may want to try renaming it.
I have tried this from fresh in another sandbox that we have, however I still receive the same error message??
Did you get a reply to this or figure it out? I'm having the same problem. The error seems to indicate that the trigger is not operating on Attachments, but there doesn't seem to be an interface to add a new "Attachment Trigger" in Salesforce because there is no menu for "Attachments" under the App Setup > Customize area of the console.
I want to set a flag on the opportunity when an attachment is added so I can add a workflow action. But this fail occurs before I attept to save it.
Even i got also same error but i fixed,
I think u r Creating trigger on opportunity object ,u need to create trigger on attachment,but it is hidden object,
so u need to write a trigger on Developer Console,In this way i fixed My problem,May This helps to u,,
Code Shows Below:
trigger restrictDelete on Attachment (before delete) {
for(attachment at:trigger.old){
at.adderror('Sorry you can\'t delete this attachment u don\'t have permission' );
}
}