You need to sign in to do that
Don't have an account?
Nathan Prats 22
Trigger Push AttachmentId To ParentId Custom Field
Hi,
My need is quite simple. I need to create a button on the Quote object to send an email with the last attachment attached.
I already created the button:
/_ui/core/email/author/EmailAuthor?
p2_lkid=0032X000023Oapf&
rtype=003
&p3_lkid={!QuoteId}&
doc_id=AttachmentId&
&retURL=%2F0{!QuoteId}
I need to Push the AttachmentId To ParentId Custom Field after the Attachement is inserted with a Trigger.
Any help is more than welcome as I'm fairly new to Apex Development.
Nathan
My need is quite simple. I need to create a button on the Quote object to send an email with the last attachment attached.
I already created the button:
/_ui/core/email/author/EmailAuthor?
p2_lkid=0032X000023Oapf&
rtype=003
&p3_lkid={!QuoteId}&
doc_id=AttachmentId&
&retURL=%2F0{!QuoteId}
I need to Push the AttachmentId To ParentId Custom Field after the Attachement is inserted with a Trigger.
trigger PushAttachmentIdToParentIdCustomField on Attachment (After Insert) { }Only problem is... I have no idea where to start.
Any help is more than welcome as I'm fairly new to Apex Development.
Nathan
Please check following sample code :
Hope this helps you!
Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com
All Answers
Please check following sample code :
Hope this helps you!
Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com
List<Quote> lstAcc = new list<Quote>();
for(Attachment a:trigger.new) {
if(a.ParentId!=NULL){
Quote ac = new Quote();
ac.id = a.ParentId;
ac.customfield__c = a.id; //attachment id assigning to customfield//
lstAcc.add(ac);
}
}
if(lstAcc.size()>0){
update lstAcc;
}
}