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
rob1961rob1961 

Static initialization of a table?

We have a trigger that does some basic geographic cleansing (e.g., mapping country abbreviation "US" to international territory "AMER", mapping U.S.A to US, etc.).

 

The trigger relies on a utility class that initializes a set of lookup tables.  For example...

 

    Map<String, String> CountryAbbreviationToInternationalTerritoryMap = new Map<String, String>();
         
    CountryAbbreviationToInternationalTerritoryMap .put('BI', 'EMEA');
    CountryAbbreviationToInternationalTerritoryMap .put('KM', 'EMEA');

    ...

 

Because there are a large number of entries to initialize the table with, we run into the "too many script statements" governor limit when this utility class is invoked from a trigger.

 

Is there a best practices for initializing a lookup table that doesn't require a lot of script statements?

 

 ~Bob


 

 

 

visulaforcevisulaforce
Create an object with 2 fields key and value. use select query in this object to pupulate Map<String, String> inside Utility's class constructor.