Skip to content

Instantly share code, notes, and snippets.

@keirbowden
Created September 5, 2014 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save keirbowden/050b1e71335e4a25f3be to your computer and use it in GitHub Desktop.
Save keirbowden/050b1e71335e4a25f3be 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;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment