Reputation: 407
I have trigger to delete records which execute after I change the status. Is it possible to delete the records after some 10 mins after I change the status.
Upvotes: 1
Views: 1307
Reputation: 19622
In addition to the other answer I'd like to point you to help related to batch jobs on salesforce. You could have a scheduled task running say every 10 minutes, checking if there's something to delete (and maybe lastModifiedDate is ealier than 10 mins ago) and wiping it out.
Or you can use System.scheduleBatch()
call to put given job in the queue of future executions only once (so it wouldn't be running all the time, only when you queued it from your trigger).
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_batch_interface.htm
Upvotes: 0
Reputation: 36
10 minutes exactly im not sure, but you can delay it for an hour using time based triggers in a workflow rule. In your trigger, instead of deleting a record, mark a boolean field "For Delete" as true, and make a worflow rule that, when that field is set to true fires a time based action 1 hour after workflow activation, marking a new field, "deleting" and a new trigger on the same object to delete any record that has that checkbox filled.
Upvotes: 1