• Jay Sanborn
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies

Folks

 

I am try to update a checkbox field on an Opportunity after I add or update an Opportunity Line Item.  Here is the code:

 

trigger CheckConfiguration on OpportunityLineItem (after insert, after update) {

      String oppID;      
      String pID;
      
      for(OpportunityLineItem oli : Trigger.new){
      
         oppID = oli.OpportunityID; 
         pID = 'Configuration';     

         if(oli.PricebookEntry.Product2.Name == pID ) {

            List<Opportunity> opps = [select Config_Required__c from Opportunity where Id = : oppID]; 
            for (Opportunity oppy: opps) {
   
                oppy.Config_Required__c = true ;

            update opps;    }
          }

      }
}

Please help and show me what I am doing incorrectly.

 

Thank You

 

Jay

 

 

Hello

 

I am trying to write a validation rule on a save or update to an opportunity that checks that the Opportunity Contains a Product (Product Type = Configuration) if the Config_Required Checkbox field is TRUE.

 

I have been trying to write a trigger but cannot get it to work.  Any thought or example would be greatly appreciated.

 

Thank You

 

Jay