+ Start a Discussion
azar khasimazar khasim 

Need to write a batch class to assign to queue(having two users) for leads which are unassigned for 1 hour from created date?

Hello Everyone,

I need to write a batch class in which the criteria.

A Batch Class in Object Lead.
When a lead is unassigned for 1 hour from created date/time then
the lead has to be assigned to a queue(Queue has two Users).

API Names 
Lead             --- Lead
Lead Owner --- OwnerId
Users Name ---  Priya
Queue Name -- PA_System_Administrator.

Please help me with a solution.

Thanks and Regards,
Azar Khasim.
Hi Azar,

You can try using time dependent workflows in your case.

Set your time depenedent work flow to fire after one hour of creation date. In your workflow criteria check fields like owner id contains or status or lastmodified to determine leads which are not yet assigned to user or queue. And choose update field action on ownerid field with Queue Id. 

Please refer below for time dependent work flow rules:
https://help.salesforce.com/articleView?id=workflow_time_dependent.htm&type=5 (https://help.salesforce.com/articleView?id=workflow_time_dependent.htm&type=5)

Hope this helps!