I have written the following queuable class :

public class LeadTriggerQueueable implements Queueable{ 
    list<Rejected_Hold_List__c> lstRejectedLead = new list<Rejected_Hold_List__c>();

    public LeadTriggerQueueable(list<Rejected_Hold_List__c> lstRejectedLead){

        this.lstRejectedLead = lstRejectedLead;
        system.debug('####lstRejectedLeadConstructor '+lstRejectedLead);

    //Method to create insert records for an sobject
     public void execute(QueueableContext context) {
         system.debug('####Inside execute');
         insert lstRejectedLead;
         system.debug('####lstRejectedLeadExecute '+lstRejectedLead);

But my execute method fails to run. I am calling this class from before insert trigger. I am not sure if i am missing something in here. Can someone point in right direction?

  • 2
    Have you checked your debug logs after trying to schedule this class in your trigger? (You haven't provided your trigger, so I can only assume that you are indeed scheduling the class.) Since it's an asynchronous operation, it'll show up as a separate log file (separate from the log file you get when your trigger that schedules this class executes).
    – Derek F
    Oct 4, 2017 at 20:01
  • Hi Derek, In my debuf i am able to get the system.debug('####lstRejectedLeadConstructor '+lstRejectedLead); in the constructor but the one in the execute is not there in the debug logs. I did not get the separate log and i checked jobs as well, queueable job was not there in the queue as well. So the execute method did not run at all.
    – SFDCSana14
    Oct 5, 2017 at 20:15

1 Answer 1


I'm going to surmise that you are trying to log objects that are failing some validation logic in your before insert trigger. If they fail, such as with .addError(), then the transaction fails and no queueables will execute by definition (nor will any asynchronous execute except Platform Event publishing)

  • So i should take off my .addError() if i need to get my queueable executed? If I take off add,error() , then my lead will be inserted and also the log object will be inserted .Is there a workaround to prevent the leads from getting inserted and only add the log object.
    – SFDCSana14
    Oct 5, 2017 at 20:22
  • @SFDCSana14 - the only way to log errors and still reject the transaction is to use Platform Events to publish the log data and then consume via a trigger. Read the doc on Platform Events for details.
    – cropredy
    Oct 6, 2017 at 22:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.