You need to sign in to do that
Don't have an account?

Trigger for creating a pricebook entry
Hi
I need some suggestions to write a trigger for the following criteria
When a Product is created or edited, create a Price Book Entry in the Standard Price Book with the Advertised Price from the input record.
Any suggestions are highly appreciated.
Regards,
Doesnt sound difficult. You'll need to run on insert and update, and test to see if the trigger is updating or inserting.
Then, if inserting just create your new pricebookentry object, populate the values based on those in the product, point the pricebook to the standardpricebook id and insert.
If updating, run a query to retrieve the existing pricebookentry, update the values and update into the database.
Hi
Thanks ministe2003 but can you explain me in detail whether the trigger should be Before or After?
from the dev guide:
In this case it probably wont make a difference but I tend to go with after in this case, so you always have the most up to date information