Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. public class attachController{
  2. public case objcase{get;set;}
  3. public Attachment myAttachment{get;set;}
  4. public string fileName{get;set;}
  5. public Blob fileBody{get;set;}
  6.  
  7. RecordType recordId = [SELECT Id FROM RecordType WHERE DeveloperName = 'Product_Case'];
  8. Id recId = (recordId != null) ? recordId.Id : null;
  9.  
  10. Group queueId = [select Id from Group where Type = 'Queue' AND DeveloperNAME = 'Product_Support_Case_Queue' LIMIT 1];
  11. Id ownerId = (queueId != null) ? queueId.Id : null;
  12.  
  13. //string recId = Schema.SObjectType.Case.getRecordTypeInfosByName().get('Product Case').getRecordTypeId();
  14.  
  15. public attachController(Apexpages.standardcontroller controller)
  16. {
  17. objcase = (Case)controller.getRecord();
  18. myAttachment = new Attachment();
  19. }
  20. public PageReference submit(){
  21. List<Contact> contacts = [SELECT Id, Email FROM Contact];
  22.  
  23. Contact con = [SELECT Id, Email FROM Contact];
  24. String conId = [SELECT Id, Email FROM Contact WHERE Email := con].Id;
  25.  
  26. if (fileName != null){
  27. objcase.RecordTypeId = recId;
  28. objcase.ownerId = ownerId;
  29. objcase.contactID = conId;
  30. insert objcase;
  31.  
  32. myAttachment = new Attachment();
  33. Integer i=0;
  34. myAttachment .clear();
  35. myAttachment.Body = fileBody;
  36. myAttachment.Name = fileName ;
  37. myAttachment.ParentId = objcase.id;
  38. insert myAttachment;
  39. } else {
  40. objcase.RecordTypeId = recId;
  41. objcase.ownerId = ownerId;
  42. objcase.contactID = conId;
  43. insert objcase;
  44.  
  45. }
  46. pagereference pr = Page.thankYouForSubmittingYourProductCase;
  47. pr.setRedirect(true);
  48. return pr;
  49. }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement