Guest User

Untitled

a guest
May 23rd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. public Pagereference ReadFile()
  2. {
  3. nameFile=contentFile.toString();
  4. filelines = nameFile.split('n');
  5. accstoupload = new List<Account>();
  6. for (Integer i=1;i<filelines.size();i++)
  7. {
  8. String[] inputvalues = new String[]{};
  9. inputvalues = filelines[i].split(',');
  10. Account a = new Account();
  11. a.Name = inputvalues[0];
  12. a.BillingStreet = inputvalues[3];
  13. a.BILLINGCITY = inputvalues[2];
  14. a.BILLINGSTATE = inputvalues[1];
  15. a.PHONE = inputvalues[4];
  16. a.STATUS__C = inputvalues[5];
  17. a.BillingLongitude = Double.valueOf(inputvalues[6]);
  18. a.BillingLocation__Longitude__s = Double.valueOf(inputvalues[7]);
  19. a.BillingLatitude = Double.valueOf(inputvalues[8]);
  20. a.BillingLocation__Latitude__s= Double.valueOf(inputvalues[9]);
  21. a.RecordTypeId = inputvalues[10];
  22. a.Brick__c = inputvalues[13];
  23. a.ParentId = inputvalues[14];
  24.  
  25. accstoupload.add(a);
  26.  
  27.  
  28. }
  29. try{
  30. insert accstoupload;
  31. }
  32. catch (Exception e)
  33. {
  34. ApexPages.Message errormsg = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured. Please check the template or try again later');
  35. ApexPages.addMessage(errormsg);
  36. }
  37. return null;
  38. }
  39.  
  40. public List<Account> getuploadedAccounts()
  41. {
  42. if (accstoupload!= NULL)
  43. if (accstoupload.size() > 0)
  44. return accstoupload;
  45. else
  46. return null;
  47. else
  48. return null;
  49. }
Add Comment
Please, Sign In to add comment