Table of Contents

Search

  1. Preface
  2. Introduction to Informatica Cloud MDM - Customer 360 for Salesforce
  3. Configuring the Data Cleansing Settings
  4. Managing Batch Jobs
  5. Verifying Addresses, Email Addresses, and Phone Numbers
  6. Synchronizing Salesforce Records with CC360
  7. Managing Duplicate Records
  8. Consolidating Records
  9. Converting External Records to Salesforce Records
  10. Managing Hierarchies
  11. Integrating Cloud MDM - Customer 360 for Salesforce with Multidomain MDM
  12. Managing Multi-Org
  13. Troubleshooting
  14. Custom Settings
  15. Glossary

Step 6. Create an Apex Trigger for the Custom Object

Step 6. Create an Apex Trigger for the Custom Object

Apex triggers enable you to perform custom actions before or after changes to the Salesforce records, such as insertions, updates, or deletions. The trigger code is stored as metadata under the custom object.
  1. Based on the Salesforce environment that you use, perform one of the following tasks:
    • In Salesforce Classic, in the upper-right corner of the page, select your name, and click
      Developer Console
      .
    • In Lightning Experience, click the quick access menu ( The image shows the quick access menu. 
				  ), and then click
      Developer Console
      .
  2. In the
    Force.com Developer Console
    window, under
    File
    , select
    New
    Apex Trigger
    .
    The
    New Apex Trigger
    window appears.
  3. Enter a name for the trigger.
    The name of the trigger should be the same as the API name of the custom object.
  4. Select the custom object.
  5. Click
    Submit
    .
  6. In the trigger editor, enter a sample Apex code in the following format to create a trigger for the custom object:
    trigger <TriggerName> on <CustomObject_API_Name> (after delete, after insert, after undelete,after update, before delete, before insert, before update) { DSE.API_CustomScoutClass cs =new DSE.API_CustomScoutClass('<CustomObjectName_API_Name>'); List<<CustomObject_API_Name>> <Variable1> = Trigger.new; List<<CustomObject_API_Name>> <Variable2> = Trigger.old; if (Trigger.isAfter) { if (<Variable1> != null) <Variable1> = <Variable1>.deepClone(true, true, true); if (<Variable2> != null) <Variable2> = <Variable1>.deepClone(true, true, true); } cs.triggerSynchronize((List<SObject>) <Variable1>, (List<SObject>) <Variable2>, Trigger.isInsert, Trigger.isUpdate, Trigger.isUnDelete, Trigger.isBefore, Trigger.isAfter); }
    The Apex code sample uses the following parameters:
    • TriggerName
      . Name of the trigger that you create.
    • CustomObject_API_Name
      . API Name of the custom object for which you create the trigger.
    • Variable1
      and
      Variable2
      . Variables used in the Apex code.
    The following example Apex code creates a trigger named
    EmployeeTrigger
    for the custom object
    Employee__c
    :
    trigger EmployeeTrigger on Employee__c (after delete, after insert, after undelete, after update, before delete, before insert, before update) { DSE.API_CustomScoutClass cs = new DSE.API_CustomScoutClass('Employee__c'); List<Employee__c> newEmployee = Trigger.new; List<Employee__c> oldEmployee = Trigger.old; if (Trigger.isAfter) { if (newEmployee != null) newEmployee = newEmployee.deepClone(true, true, true); if (oldEmployee != null) oldEmployee = oldEmployee.deepClone(true, true, true); } cs.triggerSynchronize((List<SObject>) newEmployee, (List<SObject>) oldEmployee, Trigger.isInsert, Trigger.isUpdate, Trigger.isDelete, Trigger.isUnDelete, Trigger.isBefore, Trigger.isAfter); }
  7. Under
    File
    , select
    Save
    .

0 COMMENTS

We’d like to hear from you!