You need to sign in to do that
Don't have an account?
Kruvi
Trigger on Pricebook and Pricebookentry
Hi all
I'm looking for a way to create a trigger on a pricebook entry that will run some logic each time a Product's price changes.
The problem is that as far as I can see there is no why to write a trigger on procebook and procebookentry.
Am I correct in assuming this type of triggered is not possible?
Any advise what is the right way to make this work is appreciated.
Thanks
Hi,
We can't write a trigger on price book entry object
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Hi Kruvi,
According to SF docs: Triggers are only invoked for data manipulation language (DML) operations that are initiated or processed by the Java application server.
One of the operations that don't invoke trigger is "Managing Price Books".
Regards,
Anup
hmmm sry i don't have much idea about PricebookEntry
but as u mention "each time a Product's price changes."
U can write a trigger on Product
& in that trigger u can query all the PricebookEntry as PricebookEntry obj is support query & it have a field Product2Id
so it like
list<PricebookEntry> obj = [select id, Product2Id, Pricebook2Id from PricebookEntry where Product2Id =: trigger.new[0].id];
now u have the PricebookEntry object u can make any change & update it
also u have Pricebook Id also u can also query Pricebook & can make chages into it
Thank you all
I suspected triggers are not supported.
Any idea who to "catch" a price change?
If I put a trigger on Product it will not fire on price change because the price is a field of the priceBookEntry not the product.
Many thanks
What about schedule?
For example add addition field to the Product object (Price__c), which will mapped from PriceEntry.
Schedule will check Price__c field in the Product:
- If this field is NULL - set price from PriceEntry.
- If price in this field is the same as in PriceEntry - do nothing.
- If prices are different - implement your logic.
Nice idea :-)
In my case the "real timeness" is quite important.
I refuse to believe I'll need to implement my own pricebook :-(((
How to write the trigger for send email notification to following scenario,
When the pricebook price changed,including the standard price book Now send to Email notification.
Thanks.
In addition the process will need to mark the record in some way, in order not to retrieve them in the next run.
Assume you need to run action when the unitPrice is being changed, then create field old_unitPrice__c and at first run, if the this field
is null the scheduler will populate it with the original unitPrice.
Later the scheduler should check if unit_price <> old_unitPrice__c, if yes add some logic + set old_unitPrice__c = unitPrice.
BDW, if you need to run such process in lower frequncey it can be done with external application (e.g. java code).