• James Sally
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
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
            
  
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