Salesforce:APEX Triggers

From Melissa Data Wiki
Revision as of 00:09, 6 December 2019 by Admin (talk | contribs) (Created page with "← Clean Suite for CRM:Salesforce {{CustomTOC}} ==Apex Triggers== Some users may have the need for their Salesforce records to be valid...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

← Clean Suite for CRM:Salesforce


Apex Triggers

Some users may have the need for their Salesforce records to be validated & standardized as soon as they're entered or saved into Salesforce. In that case, an Apex Trigger would be appropriate for that. Setting up an apex trigger for Clean Suite involves going into Salesforce Setup and creating a new trigger on the object you would like the trigger to run on. Below is an example of an apex trigger for invoking the Global Address component on the Contact object after a record has been inserted or updated:

trigger globalAddress on Contact (after insert, after update) {
    for (Contact contact : Trigger.new) {
        if (!Test.isRunningTest()) {
            if(!System.isFuture() && !System.isBatch()) {
             MDPERSONATOR.MD_GlobalAddressWSExt.doOneGlobalAddress((String)contact.Id);
            }
        }
    }
}

The highlighted portion in the code snippet below can be changed to use the other components:

MDPERSONATOR.MD_GlobalAddressWSExt.doOneGlobalAddress((String)contact.Id);

  • MD_GlobalEmailWSExt.doOneGlobalEmail
  • MD_GlobalPhoneWSExt.doOneGlobalPhone
  • MD_PersonatorWSExt.doOnePersonator
  • MD_PropertyV4WSExt.doOneLookupProperty