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
jlensingjlensing 

Apex code to move records between queues

I'm fairly new to apex and I have this grand idea to dynamically move custom object records from one queue to another based on the record contact time zone.

 

My initial thought was to build an apex class for each scenario (i.e. at 5am only East Coast items are in the queue, 6am Eastern and Central etc.) and then use either cronKit or apex scheduler to run the classes.

Is this a good approach? Has anyone ever tried something like this?

kennedymankennedyman

You mean, assign a record to a particular queue depenging on the time zone of an associated contact??

 

If so, you may be able use workflow for this. 

 

If not, you shouldn't have to write more than one trigger/class.

 

You would write a trigger that runs after insert or after update (before insert or update might work too, not sure in this case). Have your code retrieve the time zone of the associated person and then have your code set the "owner" of the record based on your time zone logic.