You need to sign in to do that
Don't have an account?
Cloud_BK
First Trigger
Hi All,
I am a noobie when it comes to triggers and I am trying to write my first one.
Here is the scenario:
I have a custom object called Registrants__c which has a lookup field to the standard SF object of product.
I would like to populate the Course_Price__c field on the Registrants object with the list price for the selected product. I believe I need to call the "Price_Book_Entry" object but am unsure of how to procede.
Also, I would like this to occur after insert and after update.
Any help would be much appreciated, thanks!
Brian
Here is what I have started. Appologies for any obvious errors
trigger AutoPopulateCoursePrice on cld_Registrants__c (after insert, after update) {
List<PricebookEntry> pb = new List<PricebookEntry>() ;
pb = [Select Product2Id From PricebookEntry] ;
List<PricebookEntry> cp = new List<PricebookEntry>() ;
cp = [Select UnitPrice From PricebookEntry] ;
//This is the part I am not sure of: I want the Unit Price "cp" to be populated in the Course_Selected__c field.//
if(pb = Course_Selected__c){
upsert cp;
}
}