Allow and Prevent Duplicate Headers with the Duplicate Rule Header Property

You can allow and prevent duplicate headers in messages with the Duplicate Rule Header property. This section provides an overview of the functionality that enables you to allow or prevent duplicate headers.

Duplicate Rule

The duplicate rule is part of a duplicate management feature provided by Salesforce to manage duplicate data. This feature enables you to define new duplicate rules and manage them to avoid duplicate records and data. Salesforce enables you to manage duplicate records through the SOAP API with the help of a header called Duplicate Rule Header.

The Duplicate Rule Header consists of three properties:

  • Allow Save: Allows duplicate records when set to true (that is, selected) and prevents duplicate records from being saved when set to false (that is, deselected).

  • Include Details: Returns fields and values along with the IDs of the records detected as duplicates when set to true (that is, selected) and retrieves only IDs for the records detected as duplicates when set to false (that is, deselected).

  • Run As Current User: Enables or disables sharing rules for the current user. When set to true (that is, selected), ensures that sharing rules for the current user are enforced when duplicate rules run. When set to false (that is, deselected), the sharing rules specified for the request are used.

Duplicate Error

The duplicate error carries information about the business error that occurs when a user creates a record that violates the duplicate rule.
  • This is an extended data type of the error element.

  • The duplicate result represents the details of duplicate records that are detected by the duplicate rule and information about those duplicate records.

Duplicate Rule Header in Oracle Integration Cloud Salesforce Plugin

The Duplicate Rule Header consists of the following components:

  • Duplicate rule: The Salesforce plugin supports all header properties of the duplicate rule. These three properties are handled in a mutually exclusive way. That is, if the property Allow Save is set to true (that is, selected), the other two header properties Include Details and Run As Current User change to false (that is, are deselected) and unavailable for editing. Similarly, if Allow Save is set to false (that is, deselected) the other two headers change to true (that is, selected) and are available for editing.

  • Duplicate result: The Duplicate Rule Header results as an extended type of error (DuplicateError type).

    • This error type contains different fields that carry information related to duplicate records detected by the duplicate rule.

    • Because this is an extended error, the user must substitute the error with DuplicateError to make use of it.

Allow Duplicate Records with the Duplicate Rule Header Property

You can allow duplicate records with the Duplicate Rule Header property.

Prerequisites:

  • Configure and activate at least one matching rule under Duplicate Management in the respective Salesforce organization account.

  • Configure and activate at least one duplicate rule under Duplicate Management for the respective active matching rule created. You can see the one created matching rule and the one duplicate rule in the Salesforce account that is configured to maintain the unique Phone field value for the Account object.

  1. Create a new integration (for this example, a Basic Routing integration pattern is selected).
  2. Configure a SOAP Adapter for the trigger connection.
    1. Drag and drop a SOAP Adapter connection to the trigger/source side.
    2. On the Basic Info page, specify an endpoint name, and click Next.
    3. On the Operations page, accept the default values, and click Next.
    4. On the Headers page, accept the default values, and click Next.
    5. On the Summary page, click Next.
  3. Configure a Salesforce Adapter for the invoke connection.
    1. Drag and drop a Salesforce Adapter to the invoke/target side.
    2. On the Basic Info page, specify an endpoint name, and click Next.
    3. On the Action page, select Create, Update Or Delete Information.
    4. On the Operations page, select Create in the Select an Operation field.
    5. Select Account in the Select Business Objects table.
    6. On the Headers page, ensure that Allow Save is set to true under Duplicate Rule Header and All Or None Header is set to false.

      Note:

      When Allow Save is set to true (that is, selected), Include Record Details and Run As Current User remain set to false (that is, deselected), and vice versa.
    7. On the Summary page, review your selections, and click Done.
  4. Configure request mapping.
    1. Click the Request mapping icon for editing.
    2. Map the required elements.
      • Account > Name field: This is a mandatory field.

      • Account > Phone field: This is configured for a duplicate rule that does not allow duplicate phone numbers in your Salesforce account.

    3. Click Validate, then click Close.
  5. Configure response mapping.
    1. Click the Response mapper icon for editing.
    2. Map the required elements:
      • Map Id and Success to output1 and output2, respectively.

      • Because All Or None Header is set to false (that is, deselected), you get a business error response in the createResponse tree instead of the Fault tree (unexpected error fault).

      This enables you to also map error elements. To map error elements, Salesforce returns different types of errors during runtime:
      • A generic Error element.

      • A DuplicateError element that is an extension of the generic Error element.

    3. Click Repeat Element to map both errors to the same element.
    4. Click Validate, then click Close.
  6. Add a business tracking variable.
    1. Click Tracking.
    2. Map the business identifier as a tracking variable.
  7. When complete, save and activate the integration.
  8. Once activated, use the endpoint URL to trigger the requests.

Prevent Duplicate Records with the Duplicate Rule Header Property

You can prevent duplicate records with the Duplicate Rule Header property.

Prerequisites:

  • Configure and activate at least one matching rule under Duplicate Management in the respective Salesforce organization account.

  • Configure and activate at least one duplicate rule under Duplicate Management for the respective active matching rule created. You can see the one created matching rule and the one duplicate rule in the Salesforce account that is configured to maintain the unique Phone field value for the Account object.

  1. Create a new integration (for this example, a Basic Routing integration is selected).
  2. Configure a SOAP Adapter for the trigger connection.
    1. Drag and drop a SOAP Adapter connection to the trigger/source side.
    2. On the Basic Info page, specify an endpoint name, and click Next.
    3. On the Operations page, accept the default values, and click Next.
    4. On the Headers page, accept the default values, and click Next.
    5. On the Summary page, click Next.
  3. Configure a Salesforce Adapter for the invoke connection.
    1. Drag and drop a Salesforce Adapter to the invoke/target side.
    2. On the Basic Info page, specify an endpoint name, and click Next.
    3. On the Action page, select Create, Update Or Delete Information.
    4. On the Operations page, select Create in the Select an Operation field.
    5. Select Account in the Select Business Objects table.
    6. On the Headers page under Duplicate Rule Header, ensure that Include Record Details and Run As Current User are set to true (that is, selected) and Allow Save is set to false (that is, deselected). These settings configure Duplicate Rule Header to prevent duplicate records from being created.
    7. Set All Or None Header to false.
    8. On the Summary page, review your selections, and click Done.
  4. Configure request mapping.
    1. Click the Request mapping icon for editing.
    2. Map the required elements.
      • Account > Name field: This is a mandatory field.

      • Account > Phone field: This is configured for a duplicate rule that does not allow duplicate phone numbers in your Salesforce account.

    3. Click Validate, then click Close.
  5. Configure response mapping.
    1. Click the Response mapper icon for editing.
    2. Map the required elements:
      • Map Id and Success to output1 and output2, respectively.

      • Because All Or None Header is set to false (that is, deselected), you get a business error response in the same path instead of an unexpected error fault.

      This enables you to also map error elements. To map error elements, Salesforce returns different types of errors during runtime:
      • A generic Error element.

      • A DuplicateError element that is an extension of the generic Error element.

    3. Click Repeat Element to map both errors to the same element.
    4. Click Validate, then click Close.
  6. Add a business tracking variable.
    1. Click Tracking.
    2. Map the business identifier as a tracking variable.
  7. When complete, save and activate the integration.
  8. Once activated, use the endpoint URL to trigger the requests.