+ Start a Discussion
Mahesh Babu 187Mahesh Babu 187 

Create a new record of a custom object having field value from Standard Price object

I have a requirement to create a new record of a custom object. This custom object should be populated with List Price field value of Standard Price Object. I was trying to create it with Process Builder. But process builder doesn't have option of Standard Price Object in add object section. Please help me what approach needs to be followed.
If it can be done through trigger, please share a sample code.

Thanks,
Mahesh
Best Answer chosen by Mahesh Babu 187
Abhishek BansalAbhishek Bansal
Hi Mahesh,

Yes you can use triggers for this case, please follow the below steps:
  1. Add trigger on Product object. Context would be after insert and after update.
  2. Just check if the conditions that you are checking are fulfilled and If Yes, than simply create a new record for your custom object.
  3. You can directly get teh fields from product object itself as Name and Unit Price are available on it.
Let me know if you need any other help on this.

Thanks,
Abhishek Bansal. 

All Answers

Abhishek BansalAbhishek Bansal
Hi Mahesh,

Can you please provide some more details like when you want to create new records in this object and from where you want to get the field information. 

Thanks,
Abhishek Bansal.
Mahesh Babu 187Mahesh Babu 187
Hi Abhishek,

I have a Product Object and it has 2 related objects "Standard Price" and "Custom_Object".It should create a new record of  my "Custom_Object".
The record should only be created when:

1. Product Object's  Vertical__c == 'X'
2. Product Object's Pricing__c == false

The "Custom_Object" should have fields populated in it. First field is "Product Name" from Product object and second field is "Standard Price" from  Standard Price object. Process builder doesn't have option of Standard Price Object in add object section. Standard Price and Custom_Object doesn't have any relatioship between them. Please help me what approach needs to be followed.
If it can be done through trigger, please share a sample code.
Abhishek BansalAbhishek Bansal
Hi Mahesh,

Yes you can use triggers for this case, please follow the below steps:
  1. Add trigger on Product object. Context would be after insert and after update.
  2. Just check if the conditions that you are checking are fulfilled and If Yes, than simply create a new record for your custom object.
  3. You can directly get teh fields from product object itself as Name and Unit Price are available on it.
Let me know if you need any other help on this.

Thanks,
Abhishek Bansal. 
This was selected as the best answer
Mahesh Babu 187Mahesh Babu 187
Hi Abhishek,

I don't want to populate Unit Price field value from the Product object. I want to populate Standard Price field value from the Standard Price object. Attaching the screenshot.
Standard Price
Abhishek BansalAbhishek Bansal
Hi Mahesh,

I check the below document and unfortunately the standard price field is not available on any of the object. You can also check ths for your reference:
https://help.salesforce.com/articleView?id=products_fields.htm&type=5 (https://help.salesforce.com/articleView?id=products_fields.htm&type=5)

This field is mentioned in the PriceBookEntry table but still we cannot access it through SOQL.

Thanks,
Abhishek Bansal.