function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mxalix258mxalix258 

Trigger based on Field Update

Hi All,

 

I am trying to work through creating a trigger that will create a new record in a different object, when a specific stage is reached. For example, when the Stage=signed and InternalApp=true on the Application__c object we want it to trigger the creation of a record on a different object.

 

Most of the triggers I see are creating records, on the insertion of another record. Can someone point me in the right direction for a trigger based off an update of another record?

 

Thanks for your help.

 

Alix

Jaffer Ali.Jaffer Ali.

Hello Alix,

Triggers can be fired on different event which includes insert , update , delete and undelete. For your case you need to make trigger on Update event.

 

Please see chapter on triggers from the link below.

http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content%2Fapex_shopping_cart_example.htm

 

 

 

mxalix258mxalix258
trigger createnewhire on Application__c (after update) {   
  
List<Onboarding__c> newhire = new List<Onboarding__c>();

    for (Application__c newhire: Trigger.New)

         if (Application__c.Stage__c == 'Signed'){

                 newhire.add (new Onboarding__c(

                     Name = '',
                     Owner = ''));   
         }

   insert newhire;

 }

Can someone review the code above with what I am trying to do?