• S. Kumar
  • NEWBIE
  • 30 Points
  • Member since 2011

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies
I've been trying to get the new Queueable Interface to work using API version 32.  Developer console keeps giving me "Invalid Interface name provided".  Anyone experimented with this and get it to work?
I've been trying to get the new Queueable Interface to work using API version 32.  Developer console keeps giving me "Invalid Interface name provided".  Anyone experimented with this and get it to work?

Im getting an error that says too many script statements:20001. Does anyone know how to overcome this. here is the code snipet where im getting this error

public PageReference Upload()
    {
    	
    	
        if(IsTest == null)
            IsTest = False;            
        if(!IsTest && (contentFile.Tostring() == null || contentFile.Tostring() == ''))
        {
            ApexPages.Message msg = new ApexPages.Message(ApexPages.severity.ERROR,'Please select the data csv file to insert!');
                ApexPages.addMessage(msg);
                return null;
        }
        
        
        
        // Get all the fields of object selected in the form of map
        String errorOccuredRow = ''; 
        String errorOccuredCol = '';         
        String sMsg = '';
        Map<String, Schema.SObjectField> objectFieldMap = null;
        if(selObject == 'Asset')
        {
            objectFieldMap = Schema.getGlobalDescribe().get('sevro_Terra_Asset__c').getDescribe().fields.getMap();
        }
        else
            objectFieldMap = Schema.getGlobalDescribe().get(selObject).getDescribe().fields.getMap();
        
        List<String> lFileRows = new List<String>();
        try 
        {
            if(IsTest == null)
                IsTest = False;
            if(!IsTest)
            {
                //It Splits all the rows of file in array
                lFileRows = contentFile.toString().split('\n');
                
            }
            else
            {
                lFileRows = sTest.split('\n');
            }
            // First column of file contains name of columns
            String[] columnList = lFileRows[0].split(',');
            // If selected object is Account
            if(selObject == 'Account')
              {
                List<FieldMappingAccount__c> lFieldMapping = new List<FieldMappingAccount__c>();
                Map<String,String> mFieldInfo = null;
                lFieldMapping = FieldMappingAccount__c.getAll().values();
                mFieldInfo = new Map<String,String>();
                for(FieldMappingAccount__c obj:lFieldMapping)
                {
                    mFieldInfo.put(String.valueOf(obj.Name),String.valueOf(obj.SFDC_Field_API_Name__c));
                }
                  
                  //Iterate each file record except Header row which have column name
                  for(integer i = 1; i < lFileRows.size(); i++)
                  {
                   // Array stores values of individual row record
                   String[] arrRowValues = lFileRows[i].split(',');
                   System.debug('Value of rows are' + arrRowValues);
        
                   // Account Object
                   Account Acc = new Account();
                   
                   // Iterate individual row array values
                   for(integer j = 0; j < arrRowValues.size(); j++)
                   {
                          
                      try
                      {
                          // On the basis of Column name from column Array( columnList[j]) 
                          String sField = mFieldInfo.get(columnList[j]);
                          Acc.put(sField,arrRowValues[j]);                
                      }
                      catch(Exception e)
                      {
                        ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Invalid Column: '+ columnList[j]));
                        return null;  
                      }
                   }
                    accList.add(Acc);
                   System.debug('Value of account list is' + accList);
                  }
                  if(accList.size() > 0)
                    insert accList;
                  sMsg = 'Total Accounts Uploaded:----->' + accList.size();
              }
              else if(selObject == 'Contact')
              {
                List<FieldMappingContact__c> lFieldMapping = new List<FieldMappingContact__c>();
                Map<String,String> mFieldInfo = null;
                lFieldMapping = FieldMappingContact__c.getAll().values();
                mFieldInfo = new Map<String,String>();
                for(FieldMappingContact__c obj:lFieldMapping)
                {
                    mFieldInfo.put(String.valueOf(obj.Name),String.valueOf(obj.SFDC_Field_API_Name__c));
                }
                  
                  //Iterate each file record except Header row which have column name
                  for(integer i=1; i < lFileRows.size(); i++)
                  {
                   // Array stores values of individual row record
                   String[] arrRowValues = lFileRows[i].split(',');
                   System.debug('Value of rows are' + arrRowValues);
        
                   // Account Object
                   Contact Cont = new Contact();
                   
                   // Iterate individual row array values
                   for(integer j = 0; j < arrRowValues.size(); j++)
                   {
                      try
                      {
                          // On the basis of Column name from column Array( columnList[j]) 
                          String sField = mFieldInfo.get(columnList[j]);
                          Cont.put(sField,arrRowValues[j]);
                      }
                      catch(Exception e)
                      {
                        ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Invalid Column: '+ columnList[j]));
                        return null;  
                      }
                   }
                   
                   lCont.add(Cont);
                  }
                  if(lCont.size() > 0)
                    insert lCont;
                  sMsg = 'Total Contacts Uploaded:----->' + lCont.size();
              }
            else if(selObject == 'Asset')
            {   
                   
                List<FieldMapping__c> lFieldMapping = new List<FieldMapping__c>();
                Map<String,String> mFieldInfo = null;
                lFieldMapping = FieldMapping__c.getAll().values();
                mFieldInfo = new Map<String,String>();
                for(FieldMapping__c obj:lFieldMapping)
                {
                    mFieldInfo.put(String.valueOf(obj.Name),String.valueOf(obj.SFDC_Field_API_Name__c));                    
                }
                
              for( Integer i = 1 ; i < lFileRows.size() ; i++ )
              {
              	
                // Array stores values of individual row record
                String[] arrRowValues = lFileRows[i].split(',');
                CSVAssetModel assetModel = new CSVAssetModel();
                String rowType = null;
                assetModel.sRowType = '';
                
                /*
                if(arrRowValues.get(0) != null)
                    rowType = arrRowValues.get(0).trim();
                assetModel.sRowType = rowType;
                */
                if(arrRowValues.get(0) != null)
                {
                    assetModel.sPattel_Tag = arrRowValues.get(0).trim();
                    allSerials.add(assetModel.sPattel_Tag);
                }
                if(arrRowValues.get(1) !=null)
                    assetModel.sCategory = arrRowValues.get(1).trim();
                if(arrRowValues.get(2) !=null)
                    assetModel.sDescription = arrRowValues.get(2).trim();
                if(arrRowValues.get(3) !=null)
                    assetModel.sManufacturer = arrRowValues.get(3).trim();
                if (arrRowValues.get(4) != null)
                    assetModel.sModel= arrRowValues.get(4).trim();
                if(arrRowValues.get(5) != null)
                    assetModel.sQty = arrRowValues.get(5).trim();
                if(arrRowValues.get(6) != null)
                    assetModel.scondition = arrRowValues.get(6).trim();
                if(arrRowValues.get(7) != null)
                    assetModel.ssellerRack = arrRowValues.get(7).trim();
                 if(arrRowValues.get(8) != null)
                    assetModel.spalletTotalWeight =  arrRowValues.get(8).trim();
                if(arrRowValues.get(9) != null)
                    assetModel.sTotal_Qty = arrRowValues.get(9).trim(); 
                   
           
                sevro_Terra_Asset__c SevroTerraAsset = new sevro_Terra_Asset__c();
               SevroTerraAsset.put('Name',assetModel.sPattel_Tag );
                //SevroTerraAsset = Schema.SobjectType.newSObject(newID);
                // Iterate individual row array values
                
                for(integer j = 2; j < columnList.size(); j++)
                {
                    system.debug('Nitin---mFieldInfo->'+ mFieldInfo);
                    system.debug('Nitin---mFieldInfo->'+ mFieldInfo.get(columnList[j]));
                    system.debug('Nitin---columnList[j]->'+columnList[j]);
                    
                    // On the basis of Column name from column Array() 
                    String sField = String.valueOf(mFieldInfo.get(columnList[j]));
                    
                    system.debug('Nitin---sField->'+ sField);                   
                    
                    if(sField != null && sField.length() > 0 && arrRowValues[j] != null && String.valueOf(arrRowValues[j]).trim().length() > 0)
                    {
                        
                        String SFDataType = String.valueOf(objectFieldMap.get(sField).getDescribe().getType());
                        system.debug('Nitin---SFDataType->'+ SFDataType);      
                        
                                      
                        if(SFDataType == 'Schema.DisplayType.DATE')
                            SevroTerraAsset.put(sField,ConvertStrToDate(arrRowValues[j]));
                        else if(SFDataType == 'Schema.DisplayType.DATETIME')
                            SevroTerraAsset.put(sField,ConvertStrToDateTime(arrRowValues[j]));
                        else if(SFDataType == 'Schema.DisplayType.Boolean')
                            SevroTerraAsset.put(sField,Boolean.valueOf(arrRowValues[j]));
                        else if(SFDataType == 'Schema.DisplayType.Currency')
                            SevroTerraAsset.put(sField,Double.valueOf(arrRowValues[j]));
                        else if(SFDataType == 'Schema.DisplayType.Integer')
                            SevroTerraAsset.put(sField,Integer.valueOf(arrRowValues[j]));
                        else if(SFDataType == 'Schema.DisplayType.DOUBLE')
                            SevroTerraAsset.put(sField,Double.valueOf(arrRowValues[j]));
                        else if(SFDataType == 'DOUBLE')
                            SevroTerraAsset.put(sField,Double.valueOf(arrRowValues[j]));   
                        else
                            SevroTerraAsset.put(sField,String.valueOf(arrRowValues[j]));
                    }//end of if
                }//end of for
                
                
                assetModel.Sevro_Terra_Asset = SevroTerraAsset;
                csvAssetList.add(assetModel);
                
              }//end of for
            if(allSerials !=null && allSerials.size()>0)
                existingAssets = [select id, name, serialNumber__c, servo_Terra_Category__c, Description__c, Pallet_Total_Qty__c, BegInv__c from sevro_Terra_Asset__c where serialNumber__c in :allSerials];
            createAssets();
            system.debug('Nitin--serialNumberMap-> '+serialNumberMap);
            if(serialNumberMap != null && serialNumberMap.size() > 0)
                upsert serialNumberMap.values();    
            //createComponents();
            //system.debug('-----compMap-->' + assetComponentsMap);
            //if(assetComponentsMap !=null && assetComponentsMap.size()>0)
                //insert assetComponentsMap.values();         
            sMsg = 'Total Assets Uploaded:----->' + serialNumberMap.size() + '\r\t Total Components Uploaded:----->'+ assetComponentsMap.size();
            
            
        }//end of else
    }//end of try
    catch(Exception ex)
    {
       ApexPages.Message msg = new ApexPages.Message(ApexPages.severity.ERROR,ex.getMessage() + ' , serailMapvalues' +serialNumberMap.values()+ '  ' + errorOccuredCol );
       ApexPages.addMessage(msg);
    }
    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.Info,sMsg));
    return null;
  }