You need to sign in to do that
Don't have an account?
James Sally
Opportunity Line Item Trigger
Hi Folks,
I am looking for the functionality where I can have the trigger which will auto populate the Opp Line Item if I select the specific line item.
For example If I add the "ABC" Line item to the Opportunity, trigger will auto populate the another line Item "XYZ" to the same Opp.
I have one rough draft of the trigger which is not working:
trigger AutoCreateProduct on Opportunity (after insert) {
List<OpportunityLineItem> OpportunityLineItems = new List<OpportunityLineItem>();
for (Opportunity newOpportunity: Trigger.New) {
if(newOpportunityLineItem == 'ABC'){
OpportunityLineItems.add(new OpportunityLineItem(OpportunityId = newOpportunity.Id,PricebookEntryId ='01un00000000000',Quantity = 1,UnitPrice = 0)); (This should be the another Line Item "XYZ")
Experts please help me.
Thanks,
James
I am looking for the functionality where I can have the trigger which will auto populate the Opp Line Item if I select the specific line item.
For example If I add the "ABC" Line item to the Opportunity, trigger will auto populate the another line Item "XYZ" to the same Opp.
I have one rough draft of the trigger which is not working:
trigger AutoCreateProduct on Opportunity (after insert) {
List<OpportunityLineItem> OpportunityLineItems = new List<OpportunityLineItem>();
for (Opportunity newOpportunity: Trigger.New) {
if(newOpportunityLineItem == 'ABC'){
OpportunityLineItems.add(new OpportunityLineItem(OpportunityId = newOpportunity.Id,PricebookEntryId ='01un00000000000',Quantity = 1,UnitPrice = 0)); (This should be the another Line Item "XYZ")
Experts please help me.
Thanks,
James
You can use the below Code Snippet and edit accordingly.
Happy to help You!
Thanks,
Lokesh
My Blog: http://sf2learn.blogspot.in (#)
Thank you for the Reply!
Could you please elaborate the code. Where I need to put the "ABC" product detail and where to put the "XYZ" product detail?