• feelsfdc
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 8
    Replies

HI,

 

I have test method  and it's getting failing with this error : "System.Exception: No more than one executeBatch can be called from within a testmethod.  Please make sure the iterable returned from your start method matches the batch size, resulting in one executeBatch invocation."

 

this is the case when I run test case in Full sandbox. I am not getting problems in Development Sandbox.

 

Any help on this would be appreciated.

 

Thanks

 

Hi,

 

I am here with a question on Batch Apex. In the debug log, Batch Apex showing 'SQLException thrown but connection was canceled' and taking much time to complete the batch job but, completes without any errors. My question is why is it showing this message?  Moreover I am left with no clues by reading this message.

 

I am running this job in Full sandbox  which contains thousands of records. when I ran the same batch job in Development sandbox I don't find any messages in debug log and finishes so fast.

 

Any comments on this ..

 

Thanks.

Hi,

 

I have a batch apex calss and need to write testcoverage for it. In the Batch Apex , query with condition crateddate < Last_N_Days:7.   I have created a dummy record for the lead in test method. But here the problem is  this dummy record is failing to processed by the batch apex as its createddate is today.

 

I need to create a record in testmethod which satisfy query condition then only that record will process through. But createddate is a system variable and we cant set its value in test method.

 

Anyone has any suggesstions. Appreciate reply.

 

Thanks.

Hi,

 

I have  this SOQL. MemberNumbers is a list which contains membership numbers. I need to retrieve latest record of the lead which matches memership number in membernumbers list. because lead may have duplicate records with the same membership numbers. 

 

 

 

 

SOQL:               //Lead Map
         Map<string,Lead> LeadMap = new Map<string,Lead>();
          
         for( Lead lead:[select customer__c,
                                     status,
                                     createddate,
                                     Membership_Number__c
                                from Lead
                               where Membership_Number__c in :memberNumbers]){
          
           leadMap.put(lead.Membership_Number__c,lead);
           }
    

 

 

 

 

I tried by adding  'limit 1 ' at the last . but it will retrieve only one record regardless ofdifferent membership numbers. I think i need to use aggregate functions.  I tried with them too. May be I did not use them in correct way.

 

Any suggestions?

 

Thanks,

Neeraja.

Hi,

 

Here I am doing some crazy stuff. I get givenDateTime from controller and capturing it to a dattime variable using constructor of BatchApex. I want to use this dattime variable in quey. But when I use 'dtGMT' variable in quey i got some conversion errors. so, I converted GMT time(default sFDC object store GMT time) to MST time. then its working fine. But now i thought I did crazy stuff for date.. Do any work around for this without converting from GMT to MST. 

 

Appreciate any suggestions. Following is the sample code I created.

 

 

 

    global BatchMemberList (ID CampId, dateTime givenDateTime)
    {
        CampaignId=CampId;
        dtGMT= givenDateTime;
    }

    global Database.Querylocator start(Database.BatchableContext BC)
    {
      
        //converting GMT to MST and getting individaul values from the datetime

        String dtMST = dtGMT.format('yyyy-MM-dd HH:mm:ss', 'MST');
       
        String Year = String.valueOf(dtMST.substring(0, 4));
       
        String Month = String.valueOf(dtMST.substring(5, 7));  
       
        String Day = String.valueOf(dtMST.substring(8, 10));
       
        String Hours = String.valueOf(dtMST.substring(11, 13));
       
        String Mins = String.valueOf(dtMST.substring(14, 16));
       
        String Secs = String.valueOf(dtMST.substring(17, 19));

        system.debug('dtGMT'+dtGMT);
        //Datetime format
        system.debug('dtPST'+dtMST);

        string stringDateFormat = Year + '-' + Month
                                       + '-' + Day+'T'+Hours + ':'
                                       +Mins + ':' + Secs+'Z';

        system.debug('stringDateFormat'+stringDateFormat);
       
        //Query

        query = ' select  First_Name__c,Last_Name__c,State__c, '+
                '    Zip_Postal_Code__c,Comments__c ' + 
                '  from Member_List_Stage__c '+
                ' where createdDate > '+stringDateFormat+'' ;

Hi,

 

I would like to run anonymous block using IDE. but IDE is not showing me the output I was trying to get. Even I tried in System Log,but no use. For example I am trying this simple debug statement:

 

System.debug('today'+system.now());

 

I am expeting datetime to be print as output instead of  "Anonymous execution was successful.".  How can I see the output.

 

 

 

 

HI,

 

I have test method  and it's getting failing with this error : "System.Exception: No more than one executeBatch can be called from within a testmethod.  Please make sure the iterable returned from your start method matches the batch size, resulting in one executeBatch invocation."

 

this is the case when I run test case in Full sandbox. I am not getting problems in Development Sandbox.

 

Any help on this would be appreciated.

 

Thanks

 

Hi,

 

I am here with a question on Batch Apex. In the debug log, Batch Apex showing 'SQLException thrown but connection was canceled' and taking much time to complete the batch job but, completes without any errors. My question is why is it showing this message?  Moreover I am left with no clues by reading this message.

 

I am running this job in Full sandbox  which contains thousands of records. when I ran the same batch job in Development sandbox I don't find any messages in debug log and finishes so fast.

 

Any comments on this ..

 

Thanks.

Hi,

 

Here I am doing some crazy stuff. I get givenDateTime from controller and capturing it to a dattime variable using constructor of BatchApex. I want to use this dattime variable in quey. But when I use 'dtGMT' variable in quey i got some conversion errors. so, I converted GMT time(default sFDC object store GMT time) to MST time. then its working fine. But now i thought I did crazy stuff for date.. Do any work around for this without converting from GMT to MST. 

 

Appreciate any suggestions. Following is the sample code I created.

 

 

 

    global BatchMemberList (ID CampId, dateTime givenDateTime)
    {
        CampaignId=CampId;
        dtGMT= givenDateTime;
    }

    global Database.Querylocator start(Database.BatchableContext BC)
    {
      
        //converting GMT to MST and getting individaul values from the datetime

        String dtMST = dtGMT.format('yyyy-MM-dd HH:mm:ss', 'MST');
       
        String Year = String.valueOf(dtMST.substring(0, 4));
       
        String Month = String.valueOf(dtMST.substring(5, 7));  
       
        String Day = String.valueOf(dtMST.substring(8, 10));
       
        String Hours = String.valueOf(dtMST.substring(11, 13));
       
        String Mins = String.valueOf(dtMST.substring(14, 16));
       
        String Secs = String.valueOf(dtMST.substring(17, 19));

        system.debug('dtGMT'+dtGMT);
        //Datetime format
        system.debug('dtPST'+dtMST);

        string stringDateFormat = Year + '-' + Month
                                       + '-' + Day+'T'+Hours + ':'
                                       +Mins + ':' + Secs+'Z';

        system.debug('stringDateFormat'+stringDateFormat);
       
        //Query

        query = ' select  First_Name__c,Last_Name__c,State__c, '+
                '    Zip_Postal_Code__c,Comments__c ' + 
                '  from Member_List_Stage__c '+
                ' where createdDate > '+stringDateFormat+'' ;

Hi I have to update more then 100 records in my update call but the limit of the trigger is just to update only 100 records in a trigger. Please let me know how i can update more then 100 records in my trigger. Thanks Divya Prakash Goel