Skip to main content
I need to create a trigger to kick off a workflow when a field value changes.  SInce the field that's being updated is a formula field, a standard workflow rule doesn't work.

Can someone give me a crash course/instructions to create a trigger to kick off a workflow if a field value changes?
1 个回答
  1. 2015年10月2日 07:33
    Hi,

    You can use the below code :

    trigger kickOffWorkflow on CustomObject__c(before update){

    for(CustomObject__c newRecord : trigger.new){

    CustomObject__c oldRecord = trigger.oldMap.get(newRecord);

    if(oldRecord.CustomField__c != newRecord.CustomField__c){

    //Write your logic here

    }

    }

    }

    //Please replace following varibales :

    // 1. CustomObject__c with API name of your custom object on which you want to execute trigger

    // 2. CustomField__c with API name of your field on change of which you want to perform some action

    Please adjust your requirements in above trigger accordingly and let me know if you need more help on this.

    Thanks,

    Abhishek
0/9000