• Aidan Keenan
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 4
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 27
    Replies
I am trying to develop a field that will close all jobs order statuses when another field which is set  to auto increment each day goes over 30.  
Here is my trigger but this is only working when an edit is done to the job order and I press save which is not what I want. I want all job orders with days idle greater than 30 to be closed. This is my trigger so far. Any ideas how I can set this.

trigger closeJobOrder on ts2__Job__c (before update) {

    for(ts2__Job__c jobOrderStatus : trigger.new){
   
       if (jobOrderStatus.Days_Idle__c > 30)
            {
                 jobOrderStatus.ts2__Status__c ='Closed';
            }
    }
}