Creating webhooks that use Apex triggers is necessary only when building custom flows. If you use an integration app, all required webhooks and Apex triggers are created upon installation.
Note
If your organization is not currently using the Salesforce Integration Adapter, install the adapter for all users before you proceed.
To configure a Salesforce real-time export, choose the Listen for real-time data from source application option in the What would you like to do? drop-down menu.
The following fields are available:
-
sObject type: Select the Salesforce sObject type you want to export. Your list of sObject types depends on the permissions associated with your selected connection. If you add any new custom sObject types to your Salesforce account or if there are any changes to the permissions associated with the connection you selected, click Refresh () to regenerate the list. You can choose any standard or custom sObject types (i.e., account, opportunity, contact) as long as they support Salesforce triggers.
-
Required trigger: An Apex trigger code is generated automatically after selecting an sObject type. This code is required per sObject type to facilitate real-time data exports. Copy () it before creating a new trigger in Salesforce. Then, you can paste the code directly into Salesforce. However, you must change the
<name>
field and remove the "< >" symbols before saving it, or Salesforce won't validate the trigger. The name doesn't have to match the name of the Salesforce listener in the Celigo platform.Note
To deploy Apex Triggers to Production, Salesforce requires at least 75% code test coverage. You can add a test class for the trigger code coverage.
-
Reference fields: Add additional fields to the export data defined as lookup fields on the sObject in Salesforce. This setting lets you pull data from the reference fields (such as Name, AccountNumber) on the sObject.
-
Related list: Add additional fields from the related/sublist sObject to the export data defined on the sObject in Salesforce. This setting allows you to pull data from sublist fields such as Name, Email, and Department from all Contact records related to an Account record. You can also use filters only to pull filtered Contacts belonging to a specific Department.
-
Field-specific qualification criteria: These criteria look at the record before it is exported and evaluate simple conditional expressions to filter the record to decide whether it should be exported or discarded. For example, if you are exporting Account records, you can use this field to export only Accounts belonging to a specific industry. Or, if you are exporting an opportunity, you can use this field to export only those opportunities that exceed a certain amount. You can also perform more complex expressions using AND and OR operators.
-
Define qualification criteria: Click to open a dialog box where you can visually select the Field-specific qualification criteria for the real-time export. You can choose from the available fields, operators, and values (if applicable). Add another criterion by clicking , or remove one by clicking –.
-
Creating an Apex trigger is only necessary when building custom flows. If you use an Integration app, any necessary Apex triggers will be created upon installation.
Note
Salesforce requires at least 75% code test coverage to deploy Apex Triggers to production. See Add a Test Class in the Salesforce Apex Developer Guide for more information.
-
Sign in to your Salesforce account.
-
Click Settings → Setup.
-
Click Object Manager and select an object label, such as Account.
-
On the Account page, select Triggers.
-
In the Triggers section, click New.
-
Define the Apex trigger by copying it from the Celigo platform and pasting it into the Apex Trigger text box.
Danger
-
You must change the
<name>
field. It can be any name but must not include the "< >" symbols. -
The code below is not formatted for a specific sObject type. If you manually copy it from this article, you must configure the objects using SOQL. In most cases, we recommend copying the code directly from the Celigo platform once you've selected an sObject type. Then, simply change the name when you create your trigger in Salesforce.
trigger <name> on [object Object] (after insert, after update) { integrator_da__.RealTimeExportResult res = integrator_da__.RealTimeExporter.processExport(); }
-
-
Click Save.
After this, if required, you can add a test class for the trigger.
You can add a simple test class for code coverage. If the code coverage is more than 75%, you can deploy the apex trigger to Production. (See Add a Test Class in the Salesforce Apex Developer Guide for more information.)
-
Log in to your Salesforce account.
-
Use the keyword "apex class" in the search field under the Home tab.
-
In the Apex Classes page, click New.
-
In the Apex Class page, use the example provided to write your code. Make changes as required based on your sObject.
@isTest private class CeligoCaseTrigger { static testMethod void testCaseRecord() { // Create the Case Record. Test.startTest(); Case cas = new Case(Status ='New', Priority = 'Medium', Origin = 'Email'); insert cas; Test.stopTest(); } }
-
Click Save.
Comments
Article is closed for comments.