+ Start a Discussion
PossiblePossible 

Triggers not firing while using Workflow rules!!!

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.

prabhutumprabhutum

I briefly read the post (and gotta call it night) just responding as the issue could be related to order of execution -

 

 

http://www.x2od.com/2008/11/09/salesforce-order-of-execution.html

PossiblePossible

Thanks for the response..

But my problem is that , the triggers are fired in the regular basis as per the field updates in workflow rules , but the Cusotm object where m setting the next run date is not updateing after first execution..

 

Even i debugged in the if else loop and the control is going into that , only thing the object.fields are not updating.

 

Anyone faced this kind of problem , any help will be appreciated.