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
Krishna Chaitanya HotaKrishna Chaitanya Hota 

How to write the logic for time delay in Trigger?

There are two objects Contact and Custom Object. When ever we send Email from Email Services Email address along with Resume.

In Salesforce objects when the resume is parsing object the Picklist value will be New. In between the Picklist value will be In Process. When the Picklist Value changes to 'Done' the Contact gets created.

For this resume processing it will take around 5 minutes.
So would like to know if there is a workaround where the Trigger waits until the picklist values changes to done using time delay logic.

Thanks in advance!!
Balaji BondarBalaji Bondar

I dont think you can write trigger delay logic.You can try with a batch apex which will run after 5 min and check if picklist value is updated and process the records accordingly.
srikanth challasrikanth challa
What I did was just created a flow in the 'process builder' and invoked the Apex class using a  criteria instead of writing a trigger!
Hi Krishna, 
  Sounds like you just need your trigger to not perform any logic until the picklist is set to "Done" on the custom obejct?  No need for asyncronous processing or delayed executions.