I have an object with a lookup relationship to Account (so it just stores the Id), but I need the account name to be searchable in the lookup dialog for finding

Since you can't search on formula fields, I'm thinking a insert/update trigger on the related object to populate a custom text field on the child object, but can't quite get my head around how to achieve this. Effectively I need to update a field on the object that fired the trigger (which makes me think Before trigger), but pulling data from the parent (which makes me think querying the parent based on it's ID from the lookup).

What's the right way to achieve this while remaining bulkified?

                                           Portfolio Relationship
                 Product Rating          +---------------------------+
  Account     +-------------------+      | ID                        |
+---------+   | ID                <------+ Lookup to Product Rating  |
| ID      <---+ Lookup to Account |      |                           |
| Name    |   | Acct Name as text |      |                           |
+---------+   |                   |      |                           |
              |                   |      |                           |
              |                   |      |                           |
              +-------------------+      +---------------------------+

1 Answer 1


This can be achieved by Workflow rule field update which will be executed on Product Rating object.

Workflow Evaluation criteria: Evaluate the rule when a record is created, and every time it's edited

Rule Criteria: ISCHANGED(Account__c) && NOT(ISBLANK(Account__c))

Field Update as follows with formula:


For historical data updates, use data loader to take extract all of the records for Account attributes with this SOQL

SELECT Id, Account__c, Account__r.Name FROM Product_Rating__c

Then replace Account__r.Name column with the customAccountName column (the name of custom field) and finally update Product Rating through data loader.

  • Wow, of course. I'd been massively over-engineering the solution here - my brain had bulkification worries, but that's Process Builder not Workflow that has those issues. Thanks Santanu.
    – Rob Cowell
    Jan 8, 2018 at 15:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .