AttachmentClass-Salesforce


SUBMITTED BY: Guest

DATE: Jan. 22, 2014, 12:04 p.m.

FORMAT: Text only

SIZE: 981 Bytes

HITS: 4641

  1. public class uploadAttachmentAssignmentController{
  2. public Id recId{get;set;}
  3. public string fileName{get;set;}
  4. public Blob fileBody{get;set;}
  5. public boolean isSaved{get;set;}
  6. public Attachment myAttachment{get;set;}
  7. public uploadAttachmentAssignmentController(ApexPages.StandardController ctlr){
  8. recId = ctlr.getRecord().Id;
  9. isSaved = false;
  10. }
  11. public PageReference UploadFile(){
  12. isSaved = true;
  13. if(fileBody != null && fileName != null)
  14. {
  15. Attachment myAttachment = new Attachment();
  16. myAttachment.Body = fileBody;
  17. myAttachment.Name = fileName;
  18. myAttachment.ParentId = recId;
  19. insert myAttachment;
  20. // isSaved = true;
  21. system.debug('############# value of isSaved'+isSaved);
  22. }
  23. return null;
  24. }
  25. }

comments powered by Disqus