Klevr Product Documentation logo

Outbound Dataverse Stage

The Outbound Dataverse stage allows messages to be exported from the Integration Hub service to Dataverse.

Stage Overview

The Outbound Dataverse stage allows messages to be exported from the Integration Hub service to Dataverse.

Stage Definition File Location

All Outbound Dataverse stages are defined by creating an appropriately formatted JSON definition file in the following location:

interfaces
{businessUnitCode}
{domainCode}
{integrationName}
out
dv
{STAGE_NAME}.json

Stage JSON Definition File Format

The JSON definition file for an Outbound Dataverse stage is as follows:

{
  "name": "stage-name",
  "displayName": "Brief Stage Title",
  "description": "Brief description of the stage.",
  "enabled": "$env:STATUS_<INTEGRATION_NAME>",
  "source": "previous-stage",
  "concurrency": 10,
  "connectionClientId": "$env:DATAVERSE_CLIENT_ID",
  "connectionClientSecret": "$env:DATAVERSE_CLIENT_SECRET",
  "connectionTenantId": "$env:DATAVERSE_TENANT_ID",
  "environment": "$env:DATAVERSE_ENVIRONMENT_NAME",
  "changeType": "SEE CHANGE TYPE TABLE BELOW",
  "table": "tableName",
  "tableId": "primaryColumnName",
  "retryOn4xx": {
    "errorCodePath": "error.code",
    "errorMessagePath": "error.message",
    "errors": [
      {
        "errorCode": "0x80048d19",
        "errorMessage": "Error identified in Payload provided by the user for Entity"
      }
    ]
  },
  "retryPolicy": {
    "fastRetryAttempts": 5,
    "fastRetryDelay": 10,
    "slowRetryAttempts": 23,
    "slowRetryDelay": 60
  },
  "disableRetry": false,
  "emitEvent": "_result | previous-stage-name-1",
  "emitError": true,
  "emitErrorTerminateSuccess": false,
  "leaseLockName": "lock-name",
  "preLogTransformSchemaFileName": "schemas/path/to/schema/schema-name.liquid",
  "preLogTransformSchemaType": "liquid|javascript",
  "preLogTransformFormat": "json|xml|csv"
}
PropertyDescription
nameThe name of the stage.
displayNameOptional (but highly recommended). A short (3 or 4 word) "display name" for the stage, used as a "title" of the stage in the Integration Hub Portal service's self-documentation capability.
descriptionOptional (but highly recommended). A brief (10 to 15 word) description of the stage, used as a brief description of the stage's purpose in the Integration Hub Portal service's self-documentation capability. For a more detailed explanation (when needed), use the stage markdown feature.
enabledOptional boolean flag (true or false). Default is true.

Generally set via a DevOps variable. Controls if the stage is deployed enabled or not.
sourceThe source event that the stage subscribes to. See Pub/Sub Model.

Alternatively, sources may be supplied, and an array of one or more source events can be subscribed to.
concurrencyOptional number of concurrent runs permitted for the integration workflow. Default is 10.
connectionClientIdThis calls a library variable that should be populated with the Client ID of the Service Principal used to connect to the Dataverse.
connectionClientSecretThis calls a library variable that should be populated with the Client Secret of the Service Principal used to connect to the Dataverse.
connectionTenantIdThis calls a library variable that should be populated with the Tenant ID of the Service Principal used to connect to the Dataverse.
environmentRequired. The Dataverse service environment name. That is, the <environment> part of https://<environment>.crm6.dynamics.com.
changeTypeRequired. See the Change Type Options table below.
tableRequired. The name of the Dataverse table to write to.

Note: The stage appends the character "s" to the end of the supplied table name.
tableIdRequired when using the am value for changeType. The name of the primary column in the Dataverse table.
retryOn4xxOptional object which defines that the out-dv stage must inspect the payload returned by the Dataverse action, in the event of receiving an HTTP 4xx error code.

When set, the errorCodePath defines where in the JSON-based payload an error code can be found, and errorMessagePath defines where in the JSON-based payload an error message can be found. Both of these fields are mandatory. The errors array (also mandatory) must contain at least one error code/error message object. Each error object must contain either an errorCode or an errorMessage value, or both. errorCode values are a full string match, while errorMessage values are a substring match. When both errorCode and errorMessage are supplied for an error object, then both the error code and error message must match. When a match is found for an error object, the out-dv stage will retry the message transmission.
retryPolicyOptional object defining a custom retry policy. By default, an initial fast retry (with 5 attempts, 10 minutes apart) is followed by a slow retry (23 attempts, 60 minutes apart). Retry attempt values can be set to 0 to disable the fast and/or slow retry steps, if desired.
disableRetryOptional boolean flag (true or false). The default is false. When true, the stage does not attempt to retry the Dataverse operation if a retryable error is detected.
emitEventWhen the Dataverse action is successful, the stage will normally terminate. However, under certain circumstances, it may be desirable to continue integration processing.

The optional emitEvent flag can either:

Allow the response of the Dataverse call made to be output as a message from this stage, by setting the value to a hard-coded string of _result.

Allow the payload of a previously run stage to be output as a message from this stage, by setting the value to the name of the relevant previous stage. The stage must have previously been executed in the run history of the overall Integration Hub integration, with the stage's exported payload details being present in the Cloud Event Attributes section.
emitErrorOptional boolean flag (true or false). Default is false. When true, the stage will capture and emit a payload if a non-retryable error is detected, or if a retryable error is detected on the final retry attempt. See below for more info.
emitErrorTerminateSuccessOptional boolean flag (true or false). Default is false. When true, and when emitError is also true, the stage will terminate with a Successful state, rather than a Failed state, in the event of an error being detected and emitted.

When the stage is configured to operate in this way, the integration should be defined so that a subsequent stage, or series of stages, will be triggered by the emitted error payload to "handle" the error condition in such a way that reporting and alerting on the error (as would happen if the stage terminated with a Failed state) is unnecessary.
leaseLockNameOptional. See Lease Locking.

Pre-Logging Transformation

This stage supports the optional pre-logging transformation feature using the following fields:

  • preLogTransformSchemaFileName
  • preLogTransformSchemaType
  • preLogTransformFormat

See the Pre-Logging Transformation for details.

Change Type Options

changeTypeDescription
aAdd. The stage will only create a new record. If the record already exists, the stage will terminate with an error.
amAdd or Modify. The stage will "upsert" a record. If the record already exists, it will be updated; if the record does not already exist, it will be created.

Required Payload Format

This stage must be triggered with payload consisting of a single JSON object, containing key-value pairs representing the Dataverse table columns and their associated value to add or set.

For example:

{
    "primaryColumn": "GUID",
    "columnA": "Value 1",
    "columnB": "Value 2"
}
  • When using the Add change type option, the primary column of the table does not need to be part of the payload, provided the Dataverse table being written to will auto-generate a primary column ID value.
  • When using the Add or Modify change type option, then the primary column of the table must be part of the payload.
  • All table columns that are mandatory (and which cannot be auto-populated in Dataverse) must be included in the payload.

Emit Error Payload

In the event that the emitError option has been set to true and:

  • a non-retryable error is detected when calling the Dataverse service; or
  • a retryable error is detected on the final retry attempt

then the stage will emit a payload in the following format:

{
  "errorCode": xxx,
  "errorPayload": {
    // ERROR PAYLOAD FROM DATAVERSE ACTION
  }
}

The event used to emit the payload will be the full stage name with -error appended, e.g. out-dv-stage-name1-stage-name2-error.

Last updated on