I need to find a way of bypassing any workflow rules running on the BMCServiceDesk__Incident__c object so they do not run when processing my scheduled class below.

I don't want to have to go into every workflow rule that updates the BMCServiceDesk__FKStatus__c field and exclude system administrator from the rule, it would be an unnecessary maintenance overhead.

Is there a way of stopping workflow rules from running when updating a field from a scheduled apex class?

global class Change_Inc_To_Resolved Implements Schedulable{
    global void execute (SchedulableContext sc)
    public void ChangeStatusToResolved()
        List<BMCServiceDesk__Status__c> ResolvedStatus = new List <BMCServiceDesk__Status__c>();

        ResolvedStatus = [SELECT Id FROM BMCServiceDesk__Status__c WHERE Name = 'Resolved'LIMIT 1];

        List<BMCServiceDesk__Incident__c> ListIncident = new list <BMCServiceDesk__Incident__c>();

        List<BMCServiceDesk__Incident__c> updateListIncident = new list <BMCServiceDesk__Incident__c>();

        ListIncident = [SELECT Id,(SELECT Id FROM BMCServiceDesk__Incident_Service_Target__r
                                   WHERE BMCServiceDesk__ClockState__c = 'Running')
                        FROM BMCServiceDesk__Incident__c
                        WHERE BMCServiceDesk__Status_ID__c = 'Resolved' AND Id in
                        (SELECT BMCServiceDesk__FKIncident__c FROM BMCServiceDesk__Incident_Service_Target__c
                         WHERE BMCServiceDesk__ClockState__c = 'Running')LIMIT 1];

        for(BMCServiceDesk__Incident__c up: ListIncident)
            up.BMCServiceDesk__FKStatus__c = 'a4Bw0000000CiX3EAK';
        update updateListIncident;
  • 4
    No matter how you do it, you're going to have to modify the existing rules.
    – Adrian Larson
    Apr 21, 2017 at 12:07
  • 1
    Unfortunately, there is no way how you can do it in "nice" way. possible options are -- disable workflows temporarily, adjust workflows do not fire on certain logic in apex. In fact, in case if there is some workflow that should not always fire, it need to be interpreted as redudant and adjusted to fire when needed only by updating criteria. There may be an problem within business logic behind an application, solution of which is adjusting workflows
    – kurunve
    Apr 21, 2017 at 12:08
  • 1
    Are you perchance working with anyone else on this project?
    – Adrian Larson
    Apr 21, 2017 at 12:44
  • @AdrianLarson how bizarre! No but i'm guessing it's another trouble Remedyforce admin.
    – Glenn Daly
    Apr 21, 2017 at 13:09


You must log in to answer this question.

Browse other questions tagged .