• Pinnacle-Aaron
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies

I'm fairly new to Apex development and have a question on triggers and batch processes.

 

I have an AFTER INSERT trigger on Object A that executes a batch process, say, Batch 1.

 

Batch 1 builds an Object B record and inserts it.

 

Object B has an AFTER INSERT trigger that executes a batch process, say, Batch 2.

 

Batch 2 builds an Object C record and inserts it.

 

I'm receiving a "System.AsyncException: Database.executeBatch cannot be called from a batch or future method." error on Batch 2.

 

I'm assuming this is because Batch 1 hasn't completed before Batch 2 fires off?

 

Thanks,

Aaron

I have an object Foo that stores the date a picklist status is changed. Right now it changes on any object update (in other words it reflect the "last modified" date of the object) but I want to narrow the condition to only write the date if the specific picklist changes value to enable me to generate formula results based on the length of time in a specific status.

 

I tried using PRIORVALUE to detect that the picklist changed but since it is a picklist it won't compile.

 

Has anyone got an example where a trigger performs an action based a change to a picklist value on an object? Any ideas?

 

 

trigger FooStatusChange on Foo__c (before update) {
  
  if (Trigger.isUpdate) {
      for (Foo__c a: Trigger.new) {
        a.date_status_changed__c = System.today();
        }
  }

}

 

 

 

Any idea why would I get this message expecting semicolon, found ':' for the class below

 

 ;