You need to sign in to do that
Don't have an account?
TN Admin
I want to pass collection variable (Contains list of Oppty lineitems) and opportunityId to flow. Please let me know if am doing wrong.
Passing collection variable and opportyid from apex trigger to flow
I want to pass collection variable (Contains list of Oppty lineitems) and opportunityId to flow. Please let me know if am doing wrong.
trigger OpptyLineItem on OpportunityLineItem(before delete) { if(trigger.IsBefore){ if(trigger.IsDelete){ List<OpportunityLineItem> opptyLineItemList= [select Id,Name__c,OpportunityId,PricebookEntry.Product2.Name FROM OpportunityLineItem Where OpportunityId =: trigger.old[0].OpportunityId]; Map<String,Object> productAlignmentTOoppty = new Map<String, Object>(); system.debug('productAlignmentTOoppty '+ productAlignmentTOoppty); for(OpportunityLineItem Oli: opptyLineItemList){ if(Oli.Id != trigger.old[0].Id){ system.debug('test'); // productAlignmentTOoppty.put('varOpptyDel',Oli); productAlignmentTOoppty.put('varOpportunityId',Oli.OpportunityId); } } Flow.Interview.MyFlow refToFlow = new Flow.Interview.MyFlow(productAlignmentTOoppty); refToFlow.start(); } }
First - this trigger will only handle deletion on on opportunity at a time, which is not good practice.
Second - you list of line items specifies Where OpportunityId =: trigger.old[0].OpportunityId]; in the query. Within the loop, you check for if(Oli.Id != trigger.old[0].Id){... seems like you want == instead, and you don't really even need that because of the query.
Regards,
Nagendra.P