• Possible
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 11
    Replies

Hi ,

 

I am trying to insert 200 records at a time in TestMethod for Trigger but it fails saying :-

 

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, ConnectCompiere.ScheduleWorkFlow: execution of BeforeInsert caused by: System.Exception: ConnectCompiere:Too many SOQL queries: 21
Trigger.ConnectCompiere.ScheduleWorkFlow.getCompiereSetUpId.....

 

My Trigger :-

 

 

trigger ScheduleWorkFlow on Workflow__c (before insert, before update) {

// This Apex trigger is designed to fire when the batch workflow scheduler
// checks the Trigger Batch Run checkbox or when changes are made to the Batch Run
// record manually.
Set<Id> wkIds = new Set<Id>();
for (Workflow__c batchRun : Trigger.new) {

String setUpId = getCompiereSetUpId(batchRun);
    // Apex code.......... 
}public String getCompiereSetUpId(Workflow__c batchRunOld){
//System.debug('in call getCompiereSetUpId');
List<Rule__c> ruleList = [select Compiere_Setup__c from Rule__c where Workflow_Rule__c =: batchRunOld.id];
String setUpId = '';
for(Rule__c rule:ruleList){
setUpId = rule.Compiere_Setup__c;
}
return setUpId;
}}

 

 

TestMethod :-

 

 public static testMethod void TriggerTest(){
       List<WorkFlow__c> batchS = new List<WorkFlow__c>();
        for(Integer x=0; x<200;x++){
            WorkFlow__c batch = new WorkFlow__c();
            batch.Username__c = 'XXXXXX';           
            batchS.add(batch);
        }
       
        Test.startTest();
        insert batchS;
        Test.stopTest();
        
    }

 

its running ok for 20 insert , which i can understand why my problem is happening..Basically its bcoz of the SOQL limits , but can please some gimme some idea to finetune my code in trigger..

 

 

Thanks...

 

 

 

 

Can anyone please tell me or give me some links on how to create graphs/charts to represent information on SFDC page.May be something html or what ever.Using visualforce will be great..

 

 

Thanks.

Is Too many scripts is Governor limit exceed Exception..

If Yes is it gonna go off once application is certified???

 

 

Thanks.

I have created 2 workflow rules , both uses one single field update on a Custom "Schedule"(i am tryin to update this object once my workflow rule satisfies) object.

 

Now the problem is my workflow rules are working fine , but my schedule object isn't updating.

I have taken the concept of the cronkit scheduling and tryin to create schedule with 1 simple custom object.

Can anyone suggest if thrs any problem with workflow rules or trigger.

 

 

Trigger ->

 

trigger Schedule on Test_Workflow__c (before insert, before update) {
       
    for(Test_Workflow__c bs: Trigger.new) {
         
          if (bs.Runner__c == true) {          
                       
            Datetime nextrun = bs.Next_Run_Date__c;
            if(bs.Script_Type__c == 'Days') {
                nextrun = nextrun.addDays(Integer.valueOf(bs.Frequency__c));             
            } else if(bs.Script_Type__c == 'Hours') {        
                nextrun = nextrun.addHours(Integer.valueOf(bs.Frequency__c)); 
            } else if(bs.Script_Type__c == 'Minutes') {        
                nextrun = nextrun.addMinutes(Integer.valueOf(bs.Frequency__c)); 
            }
                       
           Test_Workflow__c newRun = new Test_Workflow__c(
                    Next_Run_Date__c = nextrun,
                    Runner__c = false,
                    Name = bs.Name,
                    Frequency__c = bs.Frequency__c,
                    Script_Type__c = bs.Script_Type__c);
            insert newRun;
              
            bs.Next_Run_Date__c = nextrun;
            bs.Runner__c = false;
           
          }else{
              if (bs.Test_Schedule__c == false) {
                        bs.Test_Schedule__c= true;
                        bs.Test_Schedule_2__c = false;
              } else {
                        bs.Test_Schedule__c = false;
                        bs.Test_Schedule_2__c = true;                       
              }
              Datetime nextrun = bs.Next_Run_Date__c;
             if(bs.Script_Type__c == 'Days') {
                 nextrun = nextrun.addDays(Integer.valueOf(bs.Frequency__c));             
             } else if(bs.Script_Type__c == 'Hours') {        
                 nextrun = nextrun.addHours(Integer.valueOf(bs.Frequency__c)); 
             } else if(bs.Script_Type__c == 'Minutes') {        
                 nextrun = nextrun.addMinutes(Integer.valueOf(bs.Frequency__c)); 
             }
             bs.Next_Run_Date__c = nextrun;
             bs.Runner__c = false;
          }
    }

}

 

My field update is  Runner__c = True;

 

 

1) 1st Workflow rule  ->  Test_Schedule__c = true

1) 2nd Workflow rule  ->  Test_Schedule_2__c = true

 

 

workflow are working fine , but the  Test_Workflow__c object is updating only once at the starting , after that its never updating , but if i am updating it manually then it works fine.Please tell me some workaround ,my trigger and schedules were working fine  , but after the new updations on the workflow rules , it seems they are not giving expected results......SFDC admins please help this out.

I have a class which contains functions that are used to make webservice callouts only. I need to cover these functions in my test methods but "Run Test" fails after running the first function with the following message:

(Older API) Methods defined as TestMethod do not support Web service callouts, test skipped

 

(NEW API - 15) System.TypeException: Testmethods do not support webservice callouts.

 

in this scenario I need to know how I can obtain the required coverage (75%) on my Apex class.  is there anyway that I can ignore callouts but force the test method to continue? in my class more than 75% of the code is the functions that each make a callout to an external webservice. any Idea?
 

Thanks

 

P.S: I have searched the forum and this has been posted several times but no answer yet.

So it is!!! Its the total excersizing of code not the testmethod for each method..simply awesome..

How much would it cost to hire a developer to create a comprehensive database in Salesforce for the tracking of prespective applicants and current/former program participants?

 

Another feature which would be helpful is synching Salesforce with our online application. At present, prospective applicants must access our website, fill out and print the application, hand deliver or mail the application. What we would like to do is have the application linked to Salesforce through our website. Prospective applicants can then fill out and submit online and the application automatically loads into Salesforce under the table "Perspective Applicant."

 

We would also like to be able to close a case once an applicant leaves, but still be able to track the applicant, under the closed case, for follow up purposes. 

 

We have uploaded a app from Saleforce, but it isnt exactly what we need. 

We are looking for salesforce professionals in India especially in Hyderabad to work as part of our offshore center. Please contact me at siva.devaki@mansasys.com if interested.

 

Best Regards,

Siva