0

Trigger

createCbQuoteTriggerHandler.getOpps(Trigger.new,Trigger.oldMap);

Handler class

public static void CreateOpportunity(Map<Id,Opportunity> oldData, List<Opportunity> newData){
        if(RecurringBoolean.StopRecurrsion)
        {
            Set<id> OppIdsSet = new Set<Id>();
            for(Opportunity n : newData){
                if ( n.StageName == 'Closed Won' && 
                    (oldData.isEmpty() || ( !oldData.isEmpty() && oldData.get(n.Id).StageName != n.StageName ))
                   ){
                    OppIdsSet.add(n.Id);   
                }
                
            }
New contributor
Shahzad Alam is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

1 Answer 1

1

Yes, you can do that, just provide the two parameters:

Opportunity[] newList = [SELECT StageName FROM Opportunity LIMIT 200];
Opportunity[] oldMap = new Map<Id, Opportunity>(newList.deepClone(true, true, true));
// Fix this to match the class name
TriggerHandlerClass.CreateOpportunity(newList, oldMap);

You can also just call it indirectly with some DML:

Opportunity[] newList = [SELECT StageName FROM Opportunity LIMIT 200];
update newList;

You can also change the values in the lists before calling the method if you're trying to test your logic.

Also, as a side note, your RecurringBoolean.StopRecurrsion check is invalid. You should read my answer on ideas for a better design, and why your current design should not be used.

Your Answer

Shahzad Alam is a new contributor. Be nice, and check out our Code of Conduct.

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.