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
ApexDevApexDev 

Apex Trigger to populate lookup field based on matching fields in 2 objects

Hi Experts! :) 

On Account object and Pricebook2 object I created 2 text fields - Customer_Price_Group__c. When both values in a Pricebook2 object record match the values of field in Account object record, respectively I would like fill the Price_Book__c field on Account record to populate with the name of Pricebook2 record.

Do you have any example of Apex trigger, that I can exercise and modify for my purpose?

Thank you! :) 
PriyaPriya (Salesforce Developers) 

Hey,

Check this links that matches exaacctly your requirement :- 
https://salesforce.stackexchange.com/questions/234459/apex-trigger-to-populate-lookup-field-based-on-matching-fields-in-2-objects

Kindly mark it as the best answer so that others can also refer and take help.

Regards,

Priya Ranjan