Running a Batch Job to Populate Custom Fields

Last updated: December 6, 2025

After you create a trigger (detailed in Activating Triggers Included in the Package - Routing Data to a Custom Field) the trigger will only work on newly updated records.

To populate for all existing records, you'll need to run a batch job.

Please note: this will only work on records that have an HGId populated.

 

To run the batch job, you'll need to run the following code in the Developer Console.  If you're looking to update both Accounts and Leads, you'll need to run this separately - once for Accounts and then once for Leads.

This is the code:

database.executeBatch(new HG_Insights.HGDynamicTriggersUpdateRecordsBatch('Account'));
database.executeBatch(new HG_Insights.HGDynamicTriggersUpdateRecordsBatch('Lead'));

 

1. After setting up your trigger, open the Developer Console.

Screen Shot 2024-02-15 at 3.46.20 PM.png

 

2. In the Developer Console, go to the Debug tab and select Open Execute Anonymous Window:

Screen Shot 2024-02-15 at 3.46.38 PM.png

3. Enter the APEX code provided above and click Execute:

Screen Shot 2024-02-15 at 4.00.06 PM.png

 

Here's an example of the change seen after running the batch job.  On existing accounts you should see your target field go from this:

Screen Shot 2024-02-15 at 3.46.01 PM.png

To something like this:

Screen Shot 2024-02-15 at 3.56.21 PM.png