Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Pagereference ReadFile()
- {
- nameFile=contentFile.toString();
- filelines = nameFile.split('n');
- accstoupload = new List<Account>();
- for (Integer i=1;i<filelines.size();i++)
- {
- String[] inputvalues = new String[]{};
- inputvalues = filelines[i].split(',');
- Account a = new Account();
- a.Name = inputvalues[0];
- a.BillingStreet = inputvalues[3];
- a.BILLINGCITY = inputvalues[2];
- a.BILLINGSTATE = inputvalues[1];
- a.PHONE = inputvalues[4];
- a.STATUS__C = inputvalues[5];
- a.BillingLongitude = Double.valueOf(inputvalues[6]);
- a.BillingLocation__Longitude__s = Double.valueOf(inputvalues[7]);
- a.BillingLatitude = Double.valueOf(inputvalues[8]);
- a.BillingLocation__Latitude__s= Double.valueOf(inputvalues[9]);
- a.RecordTypeId = inputvalues[10];
- a.Brick__c = inputvalues[13];
- a.ParentId = inputvalues[14];
- accstoupload.add(a);
- }
- try{
- insert accstoupload;
- }
- catch (Exception e)
- {
- ApexPages.Message errormsg = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured. Please check the template or try again later');
- ApexPages.addMessage(errormsg);
- }
- return null;
- }
- public List<Account> getuploadedAccounts()
- {
- if (accstoupload!= NULL)
- if (accstoupload.size() > 0)
- return accstoupload;
- else
- return null;
- else
- return null;
- }
Add Comment
Please, Sign In to add comment