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
Michael MMichael M 

Pass lead id to queueable apex class from trigger

Is it possible to call a queueable apex class from a trigger? Asking because I need to pass my lead id in there... Can you please provide a simple example.. 
Best Answer chosen by Michael M
VinayVinay (Salesforce Developers) 
Hi Michael,

Below is a sample snippet
trigger testlead on Lead (after insert, after update) {
    Set<Id> leadIds = new Set<Id>();
    for(Lead l : Trigger.new) {
        if(test=123) {
            leadIds.add(l.Id);
        }
    }
    Test.Sendtest(leadIds);
}



@future (callout=true)  
public static void Sendtest(Set<Id> leadIds)

https://www.infallibletechie.com/2018/10/how-to-transfer-tasks-back-to-lead.html

Thanks,
Vinay Kumar

All Answers

VinayVinay (Salesforce Developers) 
Hi Michael,

Below is a sample snippet
trigger testlead on Lead (after insert, after update) {
    Set<Id> leadIds = new Set<Id>();
    for(Lead l : Trigger.new) {
        if(test=123) {
            leadIds.add(l.Id);
        }
    }
    Test.Sendtest(leadIds);
}



@future (callout=true)  
public static void Sendtest(Set<Id> leadIds)

https://www.infallibletechie.com/2018/10/how-to-transfer-tasks-back-to-lead.html

Thanks,
Vinay Kumar
This was selected as the best answer
Michael MMichael M
Thank you!!