Data Exchange - User Guide

TABLE OF CONTENTS

Commerce Connector - Mapping Functions and Macro Support

Overview

The mapping capabilities in Commerce Connector have been enhanced to support Functions and Macro Mappings while maintaining backward compatibility with the existing YAML mapping implementation.


Supported Mappings

The following examples demonstrate the supported mapping formats.

Example 1: Direct Property Mapping

{
  "OrderNumber": "{{$Step1.data[].orderNumber}}",
  "LinkedOrderNumber": "{{$Step1.data[].linkedOrderNumber}}",
  "Status": "{{$Step1.data[].status}}",
  "StatusCode": "{{$Step1.data[].statusCode}}",
  "OrderDate": "{{$Step1.data[].orderDate}}",
  "CustomerId": "{{$Step1.data[].customer.customerId}}",
  "CustomerEmail": "{{$Step1.data[].customer.email}}"
}

Example 2: Nested Properties and Functions

{
  "dataAreaId": "usmf",
  "order.orderNumber": "{{ $Step1.data[].classNumber }}",
  "order.orderDate": "{{ FormatDate($Step1.data[].orderDate, "yyyy-MM-dd") }}",
  "order.status.status": "{{ $Step1.data[].classStatus }}",
  "order.customer.name": "{{ $Step1.data[].customerName }}",
  "order.customer.email": "{{ $Step1.data[].customerEmailId }}",
  "order.customer.conatenatednameemail": "{{ Concat($Step1.data[].customerName, " ", customerEmailId) }}",
  "order.customer.totalwithcurrency": "{{ Concat("$", Step1.data[].total) }}"
}

Supported Functions

The Commerce Connector mapping engine provides the following built-in functions.

FunctionSyntaxDescriptionExampleReturn Type
UpperUpper(value)Converts the input string to uppercase using the invariant culture.Upper("active") → "ACTIVE"string
LowerLower(value)Converts the input string to lowercase using the invariant culture.Lower("ADMIN") → "admin"string
TrimTrim(value)Removes leading and trailing whitespace from the input string.Trim(" John ") → "John"string
ConcatConcat(value1, value2, ...)Concatenates multiple values into a single string. Accepts any number of arguments.Concat("ORD-", OrderNumber) → "ORD-1001"string
ReplaceReplace(text, oldValue, newValue)Replaces all occurrences of a substring with another substring.Replace("A-B-C","-","") → "ABC"string
SubstringSubstring(text,startIndex)
Substring(text,startIndex,length)
Returns a portion of a string beginning at the specified index.Substring("ORD1001",3) → "1001"string
LeftLeft(text,count)Returns the specified number of characters from the beginning of a string.Left("ORD1001",3) → "ORD"string
RightRight(text,count)Returns the specified number of characters from the end of a string.Right("ORD1001",4) → "1001"string
LengthLength(value)Returns the number of characters in a string or the number of elements in a collection.Length("Hello") → 5long
DateTime.TodayDateTime.Today()Returns the current system date with the time component set to midnight (00:00:00).DateTime.Today()DateTime
DateTime.NowDateTime.Now()Returns the current local date and time.DateTime.Now()DateTime
DateTime.UtcNowDateTime.UtcNow()Returns the current Coordinated Universal Time (UTC).DateTime.UtcNow()DateTime
FormatDateFormatDate(date, format)Converts a date value into the specified .NET date format using the invariant culture.FormatDate(OrderDate, "yyyy-MM-dd")string
Math.RoundMath.Round(value)
Math.Round(value, digits)
Rounds a numeric value using MidpointRounding.AwayFromZero.Math.Round(10.456, 2) → 10.46double
Math.MaxMath.Max(value1, value2, ...)Returns the largest value from the supplied numeric arguments.Math.Max(10, 15, 12) → 15double
Math.MinMath.Min(value1, value2, ...)Returns the smallest value from the supplied numeric arguments.Math.Min(10, 15, 12) → 10double
Math.AbsMath.Abs(value)Returns the absolute (non-negative) value of a number.Math.Abs(-25) → 25double
Math.CeilingMath.Ceiling(value)Rounds a decimal number upward to the nearest whole number.Math.Ceiling(5.2) → 6double
Math.FloorMath.Floor(value)Rounds a decimal number downward to the nearest whole number.Math.Floor(5.9) → 5double
CoalesceCoalesce(value1, value2, ...)Returns the first argument whose value is not null. It does not treat empty strings as null.Coalesce(Customer.Email, "unknown@example.com")Depends
IsNullIsNull(value)Returns true if the supplied value is null; otherwise returns false.IsNull(Customer.Phone) → truebool
GuidGuid()Generates a new globally unique identifier (GUID).Guid()Guid
Guid.NewGuidGuid.NewGuid()Alias for Guid(). Generates a new GUID.Guid.NewGuid()Guid

Function Notes

  • Function names are case-insensitive. For example, Upper, upper, and UPPER are treated identically.
  • Functions such as Concat, Coalesce, Math.Max, and Math.Min accept a variable number of arguments.
  • Coalesce() returns the first non-null value. It does not treat an empty string ("") as null.
  • FormatDate() expects a valid DateTime value and a standard .NET date format string (for example, yyyy-MM-dd or MM/dd/yyyy).
  • Length() supports both strings and collections. Passing any other type results in an exception.
  • Substring() validates the specified indexes and throws an exception if the requested range is outside the bounds of the string.
  • Left() and Right() safely return the entire string if the requested length exceeds the string length.
  • Math.Round() uses MidpointRounding.AwayFromZero, making it suitable for financial calculations.

Macros Support in Step Configuration

Macro mappings allow data generated in previous steps of a multi-step transmission pipeline to be referenced dynamically during runtime. The mapping engine uses the pattern {{$StepN.FieldName}} to resolve values from preceding steps.

Supported Macro Locations

i. Endpoint URL (API Transmission Mode)

Macros can be used within the endpoint URL to dynamically construct API endpoints.

Syntax

{{Step1.OrderNumber}}

Example

https://api.example.com/orders/{{Step1.OrderId}}

ii. Query Parameters (API Transmission Mode)

Example

PropertyValue
KeyorderId
Value{{Step1.OrderNumber}}

iii. Header Parameters (API Transmission Mode)

Example

PropertyValue
KeyAuthorization
ValueBearer {{Step1.Token}}

iv. Custom Authentication Header Parameters (API Transmission Mode)

Example

PropertyValue
KeyX-Customer-Id
Value{{Step1.CustomerId}}

v. Pagination Parameters (API Transmission Mode)

Example

PropertyValue
IndexParams.Value{{Step1.PageNumber}}
SizeParams.Value{{Step1.RecordsPerPage}}

Global Variables

Global Variables provide a centralized, reusable key-value store for environment-specific configuration. These values can be referenced throughout a multi-step data exchange using macro expressions, reducing duplication and simplifying configuration management.

i. Environment Variables (IsSecret = 0)

Environment Variables are stored as plain text and are readable in the database. They are intended for non-sensitive configuration values that may vary across environments but do not require encryption.

Examples

KeyValueIs Secret
API_BASE_URLhttps://api.prod.example.com0
TENANT_IDTENANT-7890
WEBHOOK_TIMEOUT_MS300000
REGIONUS-EAST-10
FEATURE_FLAG_V2_APItrue0

Typical Use Cases

  • Non-sensitive API endpoints and webhook URLs
  • Configuration flags and feature switches
  • Numeric settings such as timeouts and batch sizes
  • Public identifiers including tenant IDs and region names

ii. Secret Variables (IsSecret = 1)

Secret Variables are stored as DPAPI-encrypted values in the database and are intended for sensitive information that must remain encrypted at rest.

Examples

KeyValueIs Secret
API_KEY_PROD[ENCRYPTED_CIPHERTEXT_1234]1
DB_PASSWORD[ENCRYPTED_CIPHERTEXT_5678]1
OAUTH_CLIENT_SECRET[ENCRYPTED_CIPHERTEXT_9012]1

Typical Use Cases

  • API Keys and access tokens
  • Database passwords
  • OAuth Client Secrets
  • Webhook signing secrets
  • Private encryption keys

Usage Examples

The following examples demonstrate how Environment and Secret Variables can be referenced throughout Commerce Connector configurations.

Endpoint Example

{{Env.API_BASE_URL}}/v2/products?region={{Env.REGION}}
ComponentFieldExample
API ConfigurationEndpoint{{Env.API_BASE_URL}}/v2/orders
API ConfigurationQuery Parameterskey={{Secret.API_KEY}}
API ConfigurationHeadersAuthorization: Bearer {{Secret.TOKEN}}
API ConfigurationUsername{{Env.SERVICE_ACCOUNT}}
API ConfigurationPassword{{Secret.SERVICE_PASSWORD}}
SFTP ConfigurationHost{{Env.SFTP_HOST}}
SFTP ConfigurationUsername{{Env.SFTP_USER}}
SFTP ConfigurationPassword{{Secret.SFTP_PASSWORD}}
SFTP ConfigurationRemote File Path/inbox/{{Env.TENANT_ID}}/data.csv
Blob ConfigurationConnection StringContains {{Secret.BLOB_KEY}}
Blob ConfigurationContainer Name{{Env.CONTAINER_PREFIX}}-staging
Request Body TemplateAny JSON Field{"api_key":"{{Secret.API_KEY}}"}
Pagination ConfigurationPage Size{{Env.PAGE_SIZE}} (if numeric)
Mapping TemplateAny Transformation Field{{Env.CURRENCY_CODE}}

Important Notes

  • Function names are case-insensitive and can be used in any combination of upper or lower case.
  • Macro expressions are evaluated at runtime using values from previous steps or configured Global Variables.
  • Functions and macros can be combined within the same mapping expression to perform dynamic transformations.
  • Existing YAML mappings continue to be supported, ensuring backward compatibility with previously configured Data Exchanges.
  • Global Variables should be used for reusable configuration values to avoid hardcoding environment-specific information within mappings.
  • Sensitive information such as API keys, passwords, OAuth secrets, and connection strings should always be stored as Secret Variables.

Best Practices

  • Use descriptive Step Codes to improve mapping readability.
  • Store environment-specific values as Global Variables instead of hardcoding them in requests.
  • Store all sensitive values as Secret Variables.
  • Use mapping functions to perform transformations instead of creating custom processors wherever possible.
  • Validate mappings using sample payloads before deploying to production.
  • Keep mapping expressions simple and reusable to improve maintainability.

Summary

Commerce Connector provides a powerful mapping engine that supports direct property mappings, nested object mappings, built-in transformation functions, macro expressions, and reusable Global Variables. These capabilities simplify the creation of dynamic, reusable, and environment-independent integrations while maintaining full backward compatibility with existing YAML-based mappings.

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.