Skip to main content
Conga Support

Creating an Apex Trigger for a Custom Object as a Process Object

A trigger is Apex code that executes before or after specific data manipulation language (DML) events occur, such as before object records are inserted into the database, or after records have been deleted. A list of all triggers in your organization is located in Setup under Apex Triggers. You can invoke Apex through the use of triggers. Apex triggers are stored as metadata in the application under the object with which they are associated.

A trigger is Apex code that executes before or after the following types of operations:

  • Insert.
  • Update.
  • Delete.
  • Merge.
  • Upsert.
  • Undelete.

In order for Conga Orchestrate to use a custom object you've created, you need to create a trigger and test class in a sandbox environment and deploy them to your production environment. Salesforce does not allow you to create an apex trigger or apex class directly in a production org. Refer to the Deploy from Sandbox with Change Sets module in Trailhead for instructions on the deployment process.

Follow these steps to create the trigger in a sandbox environment:

  1. In your sandbox environment, select the Settings Cog icon (in Lightning) or your name (in Classic) in the upper right corner of Salesforce.
  2. Select Developer Console.
  3. Select File.
  4. Hover over New and choose Apex Trigger.
  5. Give your trigger a descriptive name. Something like CustomObjectNameAsProcessObjectTrigger.
  6. Choose the custom object from the sObject dropdown.
  7. Select Submit.
  8. Copy/Paste the following code into the new trigger window:
    trigger TRIGGERNAME on YOUR_CUSTOM_OBJECT_API_NAME (after insert, before insert, before update, after update, before delete) {
        FSTR.COTriggerHandler.handleProcessObjectTrigger();
    }
    
  9. Replace the TRIGGERNAME in line 1 with the name of your new trigger. This will be the name you chose in step 5 above.
  10. Replace YOUR_CUSTOM_OBJECT_API_NAME with the API name of your custom object.
  11. Save the trigger by pressing Ctrl+S on your keyboard or by selecting File > Save in the top menu of the Developer Console.
  12. Close the Developer Console window.