AddressTools Premium: Trigger creation and enablement

What do the triggers do?

AddressTools has a number of features that operate during the record insert and update operations into Salesforce. This includes (but is not limited to) enforcing validation rules, updating verification statuses, standardizing fields, and populating lookup fields.

A trigger is required on the objects that contain address fields that are configured with AddressTools. Without the trigger, most functionality will not fire and other functionality may appear to not behave as intended.

What triggers are already provided with the package?

The following objects already have a trigger provided with the package. This means you don’t need to create them:

  • Account
  • Contact
  • Contract
  • Lead

If you only plan to use AddressTools exclusively on the objects noted above, you can move on to the next article.

How can I disable the triggers provided with AddressTools?

In the event that you need to disable the triggers provided with the package, or you do not plan to use AddressTools functionality on some of the preconfigured objects:

  • Go to AddressTools Administration | Settings.
  • Scroll to Trigger Setting where you will find:
    • Enable Account Trigger
    • Enable Contact Trigger
    • Enable Contract Trigger
    • Enable Lead Trigger
  • Use the pencil icon next to the appropriate setting and uncheck the field.
  • Once done, select Save.

Creating a trigger for an object not supported out the box

So you’re looking to configure AddressTools on an object other than the four provided out the box. We’ve made it as straightforward as possible to add the trigger to the desired object!

  • Go to Setup.
  • Navigate to Object Manager.
  • Locate the Object you want to create the trigger for.
  • Select Triggers and New.
  • Paste the following code snippet into the box provided.
trigger ValidateOBJECTLABELCountryFields on OBJECTAPI (before insert, before update) {  
    pw_ccpro.CountryValidator2.Validate(, Trigger.oldMap);  
  • Replace OBJECTLABEL with the label name of the object you’re creating the trigger for.
  • Replace OBJECTAPI with the API name of the object you’re creating the trigger for.
  • Select Save.

Note: to deploy a custom trigger to production, you may be required to provide code coverage to the trigger. To do this, you will need to create an apex test to insert a record to the object you created a trigger on.

Back to the AddressTools Premium installation walkthrough

Leave a Reply