• Samadhan Daud
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
ublic class MyUploadStatementController {
    public String LeadsId {get;set;}
    public List<Attachment> docs{get;set;}
    public List<Attachment> insertedDocs{get;set;}
    public string attNames{get;set;}
    
    public MyUploadStatementController(){
        LeadsId = ApexPages.currentPage().getParameters().get('Id');
        system.debug('LeadId -->'+LeadsId);
        attNames = '';
        docs = new List<Attachment>();
        insertedDocs = new List<Attachment>();
    }
    
    public pagereference prepareSFDocuments(){           
        try{     
            //system.debug('**'+leadobj);
            attNames = attNames.removeEnd('\n');
            List<string> atts = attNames.split('\n');        
            
            //sfDocs = new List<SFDocument>();       
            for(String attName:atts){
                List<string> nameSplit = attName.split('\t');
                system.debug('Attname just '+attName);
                Attachment doc = new Attachment(Name=nameSplit[0], ParentId=LeadsId );
                docs.add(doc);
                system.debug('Debug Docs '+docs);
                //SFDocument d = new SFDocument(nameSplit[0], leadobj.id,Long.valueOf(nameSplit[1]),getDisplaySize(Long.valueOf(nameSplit[1])));
                //sfDocs.add(d);
            }
            
            System.debug('Attachment List-->'+docs);
            //Integer.valueOf('***'+docs.size());
        }catch(Exception ex){ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR, ex.getMessage()+'\n'+ex.getStackTraceString());
                             ApexPages.addMessage(myMsg);}
        return null;
    }
    
    public pagereference updateDocs(){
        //Integer.valueof('pare'+parentId);
        try{
            system.debug('Dropbox docs '+docs);
            for(Attachment da : docs){
                system.debug('Inside For Loop DropBox '+da);
                da.ParentId = LeadsId;
            }
            if(docs.size()>0)
                insert docs;
            insertedDocs.addAll(docs);
            docs = new List<Attachment>();
        }catch(Exception ex){
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR, ex.getMessage());
                             ApexPages.addMessage(myMsg);
        }
        return null;
    }
    
    @RemoteAction
    public static void UploadAttachment(String LeadId){
        
    }
}