+ Start a Discussion
Natasha AliNatasha Ali 

How to write an Apex trigger to fire on a status change

I'm stuck on creating a trigger which fires when a status changes on a record on the 'Placement' object (very new to development). Basically I want the trigger to fire and call a HTTP request class when the 'Status' on the Placement object changes from '8 - Offer Accepted' to '9 - Induction Booked'.

How do I start??

Any help is much appreciated! 
Many Thanks,
Best Answer chosen by Natasha Ali
Ajay K DubediAjay K Dubedi
Hi Natasha,
Here is the Trigger :
trigger PlacementTrigger on Placement (before update) {
 Map<Id,Placement__c> newPlacList1=new Map<Id,Placement__c>();
 Map<Id,Placement__c> oldPlacList2=new Map<Id,Placement__c>();
 List<Placement__c> newPlacementList=new List<Placement__c>();
    if(Trigger.IsUpdate && Trigger.isbefore ){
 for(Id placId : newPlacList1.keySet()){
  if(oldPlacList2.get(placId).Status__c == '8 - Offer Accepted' &&
        newPlacList1.get(placId).Status__c == '9 - Induction Booked'){

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Ajay Dubedi