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
Linda 98Linda 98 

After update trigger to transfer lead back to queue


I am having a use case like this:

When user clicks on a button,based on some criteria lead which is in queue is puled and displayed to user to work.
I am saving queue name in a custom field.
I have a workflow which will b fired if status is changed to 'no answer' and updates a checkbox to true.

Now i want a trigger which will be fired after workflow field update.
it should check if checkbox is checked,if checked then assign  it back to queue  for example to testqueue.
and then has to uncheck checkbox.

this is what i did but failed.please help!!!!!

trigger Changetoleadqueue on Lead (after update) {
     List<Lead> l = [SELECT Id,checkbox,,ownerid,lastqueue FROM Lead WHERE Id IN: Trigger.newMap.keySet() limit 1];

     List<QueueSobject> queueID =[Select Queue.Id from QueueSobject where Queue.Name =:queueName limit 1];
        for( Lead lId : l)
             if(Trigger.isUpdate && Trigger.isAfter){
system.debug('>............enters o if..........');      //it is entered
             LId.Ownerid='03gL0000001889IAQ';  //hardcoded to check ifit works but no luck

try changing the event of trigegr from after update to before update .
Linda 98Linda 98
No i cant do that.Because i am updating record when user clicks button.i tried it and it errors out.
In that case use should use update statement for updating the values.
Linda 98Linda 98
I get recurrsive trigger.. I am not confident on working on that:(
Linda 98Linda 98
Any help?? Need this asap!!!!please