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
Dustin MayfieldDustin Mayfield 

How to get a product price into another custom object field

Hello - We are trying to get the standard pricebook entry price from a product into another custom object "Installed Product". There is a field called "Product Price" on "Installed Product" object that we would like to equal the price of the standard pricebook entry price. I wish we could accomplish this through a formula, but i believe it needs to be an APEX trigger which we have light familiarity on. There is a lookup on Installed Product to the product itself, so I assume we'd use that as a reference to find the price. Any guidance or help on creating this trigger would be extremely appreciated!
Shawn Reichner 29Shawn Reichner 29
If you have th elookup field pointed to the product, you absolutely should be able to just use a Formula Field.  Create a formula field (Type Currency) and point it to the Price field on the product record. 

If for some strange reason you can not do this, you could also look at process builder to when the Installed Product record is created or edited, and for your criteria state that the Lookup field on the Installed Product object is not null and is Changed to populate the Product Price field with the value form thePrice field on the Product being used in the lookup field.

Hope this makes sense and there should be two ways above to achieve this without the need for cusotm code. 

Let me know if this works or some additional information about what you are seeing if this does not work so we can help further. 

Shawn
Dustin MayfieldDustin Mayfield
Hi Shawn,

To my knowledge the price doesn't live at the product level but the pricebook entry level. There is no way to use a formula to get the price from the pricebook entry. Would you mind showing me how you can create  a lookup to a price from a formula via the lookup? Maybe i'm missing something
Shawn Reichner 29Shawn Reichner 29
Dustin,

Sorry for the confusion.  Do you also have a look up field to your Price Book listed on the Installed Product object?  How many price books do you have?  If you have criteria based on the Client the installed product is associated to, then you can use that criteria to autopopulate the correct price book with a process builder.  That is step one.  Step 2 is to then use that price book field in another process builder process to when the Product lookup field is not null and the price book field is not null on create or edit, then your actions will be to traverse through the Price Book lookup field to look at the Product Name or ID that the Product lookup field uses and then use the Price listed on that Price book to update your price field on the installed product.  

So one field on installed product and 2 proceses should be what you need to overcome this, or you can do an apex trigger to do the same work, but I would rather see you go declaritive so you can support it. 

Shawn