You need to sign in to do that
Don't have an account?
Juul
Trigger on attachment contains "RFP"
Hi,
I'm trying to create a trigger on attachment. If the attachment contains the text "RFP" then the checkbox "RFP_check__c" has to be checked.
// Trigger to update the RFP_check__c custom checkbox field in Opportunity (Opportunity) if it has an attachment containing RFP. trigger TiggerName on attachment (after insert) { List<Opportunity> co = [select id, Attachment__c from Opportunity where id =: Trigger.New[0].ParentId]; if(co.size()>0) && att.Name.toLowerCase().contains('RFP')) { co[0].RFP_check__c = true; update co; } }
Eclipse is giving me the error : Unexpected token &&
And the following error:
You have an unbalanced closing bracket. Try changing to:
Thanks, but now I'm getting the error:
Error: Compile Error: Method does not exist or incorrect signature: att.Name.toLowerCase() at line 9 column 46
That's because att doesn't exist.
You probably need to pull back the attachment name in the query and check that:
Then you can simply check attachment__r.Name.toLowerCase() ...
I'd move this to a before trigger where you can update the opportunity object in situ, otherwise you need to protect against your trigger being recursively called.
That's because att doesn't exist.
You probably need to pull back the attachment name in the query and check that:
Then you can simply check attachment__r.Name.toLowerCase() ...
I'd move this to a before trigger where you can update the opportunity object in situ, otherwise you need to protect against your trigger being recursively called.
Thanks Bob, but that isn't working ('Compile Error: Didn't understand relationship 'Attachment__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name')
I did some new search on the forum. And I found a before insert trigger. This trigger is giving an error when the file name contains shivasoft. And I need to check the field RFPcheck. Can you help me a bit, I'm quite new to triggers.
thanks
I don't have time to rewrite triggers to your specification I'm afraid. If you want to have a go and hit problems I'll endeavour to help you out.
Sorry it was a rude question. Thanks anyway for your help. I will give it a try and when I hit problems I will post it :)