• Gujjula404
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

I have thridparty service username/pwd using this service we need to impletement in salesforce application with single sign-on .

Could please any one guide me

Hi All,

User-added image

I need to uplaod more than 100 contacts and Accounts like the above CSV file format,
here 2 accounts and 13 contacts iam uploading and also duplicate not allowed for Contacts as well as Account
this is working fine when iam uploading 30 records,
But i am getting following error while uploading more than 30 records

System.LimitException: Too many SOQL queries: 101

below the code i used:
-------------------------------
public PageReference UploadAction() {
          Count=0;
    contactInsert.clear();
    dcontact.clear();
 
 
  if(csvFile!=null)
        {
           nameFile=csvFile.toString();          
               //Read the CSV Rows using split method
            filelines = nameFile.split('\n');        
         }
    for (Integer i=1;i<filelines.size();i++)
            {
                String[] inputvalues = new String[]{};
                  inputvalues = filelines[i].split(',');   
                 Contact cnt= new Contact();
                 Account Ac=new Account();
                  List<Account> al= new List<Account>();
                 cnt.FirstName= inputvalues[0];
                 cnt.LastName= inputvalues[1];
                 if(String.isNotBlank(inputvalues[2]))
                 {
                 Ac.Name=inputvalues[2];
                al=[Select id,Name from Account Where name=:Ac.Name];                 
                 if(al.size()==0)
                 {
                 insert Ac;
                 }                 
                 List<Account> Acl= new List<Account>();
                 Acl=[Select id, name from Account Where name=:Ac.Name];
                 cnt.AccountId=Acl[0].id;     
                 
                }
                
                cnt.Email= inputvalues[3];
                
                cnt.Phone= inputvalues[4];    
                List<contact> cl= new List<contact>();
                cl=[select id, email from contact where email=:inputvalues[3] and account.name=:inputvalues[2]];
               
                if(cl.size()==0)
                {
                count++;
                 contactInsert.add(cnt);
        
                 }
                 else{
              
                 cnt.AccountName__C=  inputvalues[2];
          
       
                 dcontact.add(cnt);
                 
                 
       
                 }
            }    
            
            if(count!=0)
            {
            System.Debug('-------------count value----'+ Count);
    insert contactInsert;
    count=0;
    
    }else{
 
    }
     
        return null;
    }


Thanks...!
  • April 29, 2015
  • Like
  • 0