Connect to Salesforce

On this page:

  • Learn how to connect your Salesforce CRM to eTrusted: trigger events to eTrusted at your Salesforce touchpoints
  • Call the eTrusted Events API from within Salesforce using Apex code

You will need:

  • A Salesforce system in an edition that features the Salesforce Process Builder: Salesforce Classic or Lightning Experience, as Essentials, Professional, Enterprise, Performance, Unlimited, or Developer edition

Your organisation uses a Salesforce CRM system that you want to connect with your eTrusted account?

No problem! It is reasonably easy to connect Salesforce and eTrusted via Salesforce's Apex programming language and classic REST API calls against the eTrusted API.

Follow the steps on this page for a baseline tutorial how to connect the two systems.

Import

You need two custom objects, an Apex trigger and some Apex code that works with custom objects.

There is a convenient way for creating all of that: Salesforce offers a migration function to partially dump and recreate an environment.

For that purpose we exported the required custom objects, the trigger and the code as a zip bundle for you to import.

Download and unzip our zip bundle. It contains a README, a license note and the actual Salesforce migration bundle (again, a zip file).

Do the following:

  1. Log into the Salesforce workbench.
  2. From the migration tab, select Deploy.
  3. Select the migration bundle (unmanagedPackage.zip).
  4. Select "Rollback on Error" and pick "Run Specified Tests" for Test Level.
  5. Select eTrusted_MetaHandler_Test as test class:

    Navigate to custom metadata types

Finish the import.

Remote Site Settings

Next, add two eTrusted URLs to your remote site settings:

  1. Search Setup for Remote Site Settings and click it just below Security.
  2. Click New Remote Site
  3. Enter "eTrusted API" as Remote Site Name and https://api.etrusted.com as Remote Site URL.
  4. Click Save & New.
  5. Enter "eTrusted Login" as Remote Site Name and https://login.etrusted.com as Remote Site URL.
  6. Click Save.

Credentials

It is handy to store your eTrusted credentials in Salesforce so that you can reuse them for your API calls.

It is crucial to protect your credentials - and Salesforce offers a convenient way to do that: Custom Metadata Types.

In the Salesforce web interface, do the following:

  1. Search Setup for Custom Metadata Types and click it just below Custom Code. Navigate to custom metadata types
  2. Again on the All Custom Metadata Types page, click Manage Records next to your Custom Metadata Type "eTrusted Credential".
  3. On the eTrusted Credentials page, click New just above the list.
  4. Fill in the records, using the following information: eTrusted events API credentials where Client ID and Client Secret are your eTrusted credentials.
  5. Click Save & New.
  6. Fill in the records again, using the following information: eTrusted events questionnaire links credentials where Client ID and Client Secret are your eTrusted credentials.

See Define a custom metadata type declaratively for reference.

Permissions and Visibilities

Set permissions and visibilities according to your Salesforce profiles and roles.

  1. Back in your regular Salesforce web app, search Setup for Tabs.
  2. In Custom Tabs, click New.
  3. Select "eTrusted Callout" as Object and a Tab Style that you like.
  4. Click Next two times. Select profile visibilities and Custom App settings to your liking.
  5. Click Save.
  6. In Custom Tabs, again click New and do the same for "eTrusted MetaData".
  7. In Setup, click the Object Manager tab.
  8. Scroll down and click "eTrusted Callout".
  9. In Fields & Relationships, do the following for every record:
    1. Click the record.
    2. On the record page, click Set Field-Level Security
    3. Select the Field-Level Security profiles that you want.
  10. Repeat the last steps for "eTrusted MetaData".
  11. In Setup, select Profiles from the Users dropdown menu.
  12. Click Edit for the profile you want to grant access to the custom objects, e.g. "System Administrator".
  13. Scroll down to Custom Object Permissions, and find "eTrusted Callouts" and "eTrusted MetaData".
  14. Check the Modify All box for both.
  15. Back in the Profiles page, click the profile (instead of Edit, this time).
  16. Scroll down to Custom Record Type Settings and click Edit in the "eTrusted Callouts" row.
  17. Select both Available Record Types.

eTrusted Callout Record

Create a record for eTrusted Callout:

  1. Click the App Launcher.

    icon

  2. Search eTrusted Callouts and click it under All elements.

  3. Click New and create a new entry for "eTrusted Callout".
  4. Select Event as record type and create the record like this and Save.

    Event Callout Record

  5. For eTrusted Credential, set the name from your "Custom Metadata Types" in your eTrusted Credentials under "Manage Records"

  6. Do the same for Questionnaire as record type like this:

    Questionnaire Callout Record

Note

  • The event type should be the event type or touchpoint in your eTrusted configuration, e.g. checkout.
  • If you send a questionnaire via the Events API, provide the Questionnaire Locale.
  • If you request a questionnaire link from eTrusted, provide the Questionnaire Template ID.
  • Provide channel data as defined in your eTrusted configuration, both for channel ID and channel type.

Allowed Values for Record Types

Set allowed values for your record types:

  1. In Setup, click the Object Manager tab again.
  2. Scroll down and click "eTrusted Callout".
  3. In Record Types, for each record:
    1. Click the record type.
    2. In Picklist Available for Editing, click Edit and select all Available Values for every picklist.

For example, for the channel record type, set "etrusted" and "user_defined" as allowed values like this:

Record Type Values

Process Builder

Finally, you need to regulate when your Apex code will be executed. For that, we recommend to use the Salesforce Process Builder.

In the following steps, you will create a trigger for your Apex code: Every time your Salesforce CRM creates a custom object (see above), it will be executed, handle the necessary metadata and call the eTrusted Events API.

  1. In Setup, search Process Builder in the Quick Find box.
  2. Click New.
  3. For your Process Name, type eTrusted.
  4. For The process starts when, select "A record changes".
  5. Click Save.
  6. Configure the start condition like this: Start condition graph Start condition settings
  7. Configure the criteria like this: Criteria graph Criteria settings
  8. Configure the immediate actions like this: Immediate actions graph Immediate actions settings
  9. Click Activate to activate your process.

Note

  • Make sure that the transactional reference is unique. If you want to send several events for the same case, you can do so via time stamp, for example: "#" + [Case].CaseNumber + ":" + [Case].Subject + "-" +Text(NOW()).
  • You also need to specify the object ID. It is the record ID where the event is triggered (in our case, it is the case ID).
  • The order of Keys and Values is irrelevant, however it is important that "value 1" has indeed the value of "key 1" and so on. Key-Value pairs are the actual metadata used in eTrusted. Keys can be picked to your liking.
  • If you are requesting a questionnaire link from eTrusted, set the field "Questionnaire Link OutputField" with the API name of the field where you want to save the Questionnaire Link. The field must be within the same object where the event is triggered (in this case, "case").
  • The eTrusted Event Callout must be set. It is the "eTrusted Callout" ID that we created previously. It is the part of your browser address between /eTrusted_Callout__c/ und /view (18 characters long).

See Salesforce's quick guide how to create a new process with the Process Builder for reference.