Update Products on Quote


I have a collection of OpportunityProductInterest objects on a quote, and I would like to immediately call a method of the OpportunityProductInterest class for each of them (to update price and discount information) when I change a particular field on the parent quote.

I have tried using messaging for this, but the broadcast message I send from the Quote object doesn't appear to be received.  Is there a more direct way of calling a method from each instance of a child object, or is there a way to make messaging work for this purpose?

Thank you.

Like 0



It's hard to understand what exactly you want to achieve. If you want to update all records after saving, then it's better to use a business process. If you want to update all records after changing a value in a field, then you need to use "dependencies of the calculated field", the "messages" property and the EntitySchemaQuery implementation on client. If you want to calculate all records separately it's better to write a web service. Anyway the task is not clear.

Eugene Podkovka,

The second, more or less.  I received some help from another source earlier and have the basic mechanics set up; however, it seems that the onEntityInitialized function is not being called on the detail object.  (I've put in debugger; and console.log(); statements to confirm, and neither shows up from that function in this object despite working in others.)

Is onEntityInitialized not called from a data grid, or is there another reason?  Is there somewhere else I could register the message, or do I need to update the records manually using an EntitySchemaQuery?

Darian Lewis,

Depends on the moment when you need to run the method. Anyway you still don't explain the task so it's not possible to help you. Please investigate the parents of the detail schema and debug all methods. This way you'll find the one that matches your needs. 

Eugene Podkovka,

Very well, then, in more detail:

We have a labQuote object, which contains a Price List column.  The page for quotes contains a detail showing a data grid of OpportunityProductInterest objects, these being the products on the quote.

Both the price and discount values of each product vary based on the price list of the parent quote; these values are calculated by a method of the OpportunityProductPageV2 object that is called when a Product is selected from the lookup in the data grid.  This part works fine.

What I wish to do is have these values recalculated if the user changes the Price List value of an open Quote, ideally immediately so that the user can see the effect of their changes.  Is it possible to do this through a method of the OpportunityProductPageV2 schema (i.e. the detail object), or is it necessary to make the changes from the quote (i.e. the parent object) manually using an EntitySchemaQuery?

Darian Lewis,

I recommend to create a web service that calculates the needed value for a single record. Additionally the service should be able to update a group of records using a server side EntitySchemaQuery. On the OpportunityProductPageV2 I recommend calling the service and setting up the value on a callback. This way you'll be able to update the product price in run time on the opportunity product page. 

If you need to update a group of records, then you call the same service and then call the reloadDetail (basepagev2) method on the service callback. 

Thank you.

Show all comments