Skip to content

Instantly share code, notes, and snippets.

@amrud
Forked from keirbowden/AddAttachmentExt.cls
Created March 29, 2016 04:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amrud/1d45ab75c4ee6eb695a1 to your computer and use it in GitHub Desktop.
Save amrud/1d45ab75c4ee6eb695a1 to your computer and use it in GitHub Desktop.
Extension controller to save an attachment associated with a record encapsulated in the standard controller
public with sharing class AddAttachmentExt
{
private ApexPages.StandardController stdCtrl;
public Attachment att {get; set;}
public AddAttachmentExt(ApexPages.StandardController inStd)
{
stdCtrl=inStd;
att=new Attachment();
}
public PageReference AddAttachment()
{
att.ParentId=stdCtrl.getId();
insert att;
PageReference pr=new PageReference(ApexPages.currentPage().getUrl());
pr.setRedirect(true);
return pr;
}
}
@amrud
Copy link
Author

amrud commented Mar 29, 2016

thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment