Examples
Example 1: Simple Direct Mapping
Map a source field directly to a target field:
{
"source": "MX_MAIL_PRIMARY",
"target": "data/emails[0]/value"
}Input: { "MX_MAIL_PRIMARY": "j.doe@acme.com" }Result: data.emails[0].value = "j.doe@acme.com"
Example 2: Constant Value
Set a fixed value regardless of input:
{
"constant": "work",
"target": "data/emails[0]/type"
}Result: data.emails[0].type = "work" (always)
Example 3: Value from Header
Use a message header as the source:
{
"header": "roiam_customer_system_name",
"target": "data/srcRepository"
}Result: if header roiam_customer_system_name = "REPO_NAME", then data.srcRepository = "REPO_NAME"
Example 4: Template with Multiple Sources
Combine multiple fields into one value:
{
"source": ["MSKEYVALUE", "MX_MANAGER"],
"target": "data/srcEntity/value",
"transform": "template",
"template": "query:Users?filter=userName eq '{{VALUE1}}'~id AND manager eq '{{VALUE2}}'"
}Input: { "MSKEYVALUE": "JDOE001", "MX_MANAGER": "67890" }Result: data.srcEntity.value = "query:Users?filter=userName eq 'JDOE001'~id AND manager eq '67890'"
Example 5: Conditional — Different Source by Identity Type
Use a different source field depending on whether the user is an Employee or External:
{
"target": "data/urn-._roiable-._roiam-._params-._scim-._schemas-._extension-._job-._2.0-._User/jobDetails[0]/company",
"transform": "conditional",
"conditions": [
{
"when": {
"field": "MX_FS_IDENTITY_TYPE",
"operator": "equals",
"value": "Employee"
},
"source": "MX_FS_COMPANY_CODE"
},
{
"when": {
"field": "MX_FS_IDENTITY_TYPE",
"operator": "equals",
"value": "Contractor"
},
"source": "Z_VENDOR"
}
],
"default": { "constant": "UNKNOWN" }
}Input (Employee): { "MX_FS_IDENTITY_TYPE": "Employee", "MX_FS_COMPANY_CODE": "ACME Corp" }Result: jobDetails[0].company = "ACME Corp"
Input (Contractor): { "MX_FS_IDENTITY_TYPE": "Contractor", "Z_VENDOR": "Vendor Inc" }Result: jobDetails[0].company = "Vendor Inc"
Input (Other): { "MX_FS_IDENTITY_TYPE": "Intern" }Result: jobDetails[0].company = "UNKNOWN"
Example 6: Conditional with Template Transform in Branch
Apply different formatting per condition:
{
"target": "data/displayName",
"transform": "conditional",
"conditions": [
{
"when": {
"field": "MX_FS_IDENTITY_TYPE",
"operator": "equals",
"value": "Employee"
},
"source": ["MX_FIRSTNAME", "MX_LASTNAME"],
"transform": "template",
"template": "{{VALUE1}} {{VALUE2}}"
},
{
"when": {
"field": "MX_FS_IDENTITY_TYPE",
"operator": "startsWith",
"value": "Ext"
},
"source": "DISPLAYNAME",
"prefix": "[EXT] "
}
],
"default": { "source": "DISPLAYNAME" }
}Input (Employee): { "MX_FS_IDENTITY_TYPE": "Employee", "MX_FIRSTNAME": "John", "MX_LASTNAME": "Doe" }Result: data.displayName = "John Doe"
Input (External): { "MX_FS_IDENTITY_TYPE": "External", "DISPLAYNAME": "Jane Smith" }Result: data.displayName = "[EXT] Jane Smith"
Example 7: Conditional Based on Header Value
Condition evaluated against a message header:
{
"target": "data/reason",
"transform": "conditional",
"conditions": [
{
"when": {
"field": "header:roiam_operation_mode",
"operator": "equals",
"value": "initial_load"
},
"header": "roiam_customer_system_name",
"transform": "template",
"template": "Initial load for system {{VALUE}}"
},
{
"when": {
"field": "header:roiam_operation_mode",
"operator": "equals",
"value": "delta"
},
"header": "roiam_customer_system_name",
"transform": "template",
"template": "Delta sync for system {{VALUE}}"
}
]
}Example 8: Conditional with exists Operator
Only map a field if the source value is present:
{
"target": "data/phoneNumbers[0]/value",
"transform": "conditional",
"conditions": [
{
"when": { "field": "MX_PHONE_MOBILE", "operator": "exists" },
"source": "MX_PHONE_MOBILE"
},
{
"when": { "field": "MX_PHONE_OFFICE", "operator": "exists" },
"source": "MX_PHONE_OFFICE"
}
]
}Behavior: Uses mobile phone if available, falls back to office phone, writes nothing if neither exists.
Example 9: requires — Avoid Orphan Email Object
The three rules below together build one logical email entry. Without requires, the two constants would be written even when MX_MAIL_PRIMARY is missing — producing an email object with no value.
{
"source": "MX_MAIL_PRIMARY",
"target": "data/emails[0]/value"
},
{
"constant": "work",
"target": "data/emails[0]/type",
"requires": "MX_MAIL_PRIMARY"
},
{
"constant": true,
"target": "data/emails[0]/primary",
"requires": "MX_MAIL_PRIMARY"
}Input (with email): { "MX_MAIL_PRIMARY": "j.doe@acme.com" }Result: data.emails[0] = { "value": "j.doe@acme.com", "type": "work", "primary": true }
Input (no email): { }Result: data.emails is not written at all — no orphan object.
The
valuerule itself does not needrequires; the engine already skips writes when the source resolves tonull.requiresis added to the constant rules because constants always resolve.
Example 10: requires with any — Gate on Any of Several Fields
Set jobDetails[0]/primary = "true" only when at least one job-related source field is present. Useful when many fields contribute to the same nested object and the constant should only appear if the object would otherwise have content.
{
"constant": "true",
"target": "data/.../jobDetails[0]/primary",
"requires": {
"any": [
"MX_FS_COMPANY_CODE_ID",
"MX_FS_JOB_ID",
"MX_FS_COST_CENTER_ID",
"MX_FS_ORGANIZATIONAL_UNIT_ID"
]
}
}Behavior: if any one of the listed fields has a non-empty value, primary = "true" is written. If all four are empty, the rule is skipped.
Example 11: requires with all — Gate on a Combination of Conditions
Write a constant only when the user is an employee and has a personnel number:
{
"constant": "internal",
"target": "data/userType",
"requires": {
"all": [
{
"field": "MX_FS_IDENTITY_TYPE",
"operator": "equals",
"value": "EMPLOYEE"
},
{ "field": "MX_FS_PERSONNEL_NUMBER", "operator": "exists" }
]
}
}Behavior: plain strings inside any/all are interpreted as exists checks; condition objects use the same operator set as transform: "conditional". The two forms can be mixed in the same array.
See also
- Mapping Rule Reference — rule properties and path syntax
- Transformations — transform type details