function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
KruviKruvi 

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

 

 

Navatar_DbSupNavatar_DbSup

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. 

Anup JadhavAnup Jadhav

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

SRKSRK

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

KruviKruvi

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

Eugene PozniakEugene Pozniak

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.

KruviKruvi

Nice idea :-)

 

In my case the "real timeness" is quite important.

 

I refuse to believe I'll need to implement my own pricebook :-(((

sundhar.mks1.3962649227519546E12sundhar.mks1.3962649227519546E12
Hi All,

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.

 
Liron CohenLiron Cohen
You can write schedule process, however with SF tools it can be schedule in minimum interval of 1 hour.

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).