Skip to main content

Version: 22.10

Traversing JSON properties

Instead of storing values in multiple Journey Manager Txn properties, you can store values on a single property in a JSON object and use them in Workspaces.

Let's see how this works using the following example:

Example - Txn properties
{
"Applicants.PrimaryType": "Primary",
"Applicants.PrimaryEmail": "[email protected]",
"Applicants.PrimaryName": "David Gilmore",
"Applicants.PrimarySSN": "122-313-3443",
"Applicants.SecondaryType": "Secondary",
"Applicants.SecondaryEmail": "[email protected]",
"Applicants.SecondaryName": "Matt Green",
"Applicants.SecondarySSN": "111-233-1234"
}
Example - Global Mappings config
{
...
mappings: {
...
$primaryType: {
label: 'Type',
dataIndex: 'properties["Applicants.PrimaryType"]',
type: 'text',
},
$primaryName: {
label: 'Name',
dataIndex: 'properties["Applicants.PrimaryName"]',
type: 'text',
},
$primaryEmail: {
label: 'Email',
dataIndex: 'properties["Applicants.PrimaryEmail"]',
type: 'text',
},
$primarySSN: {
label: 'SSN',
dataIndex: 'properties["Applicants.PrimarySSN"]',
type: 'text',
},
$secondaryType: {
label: 'Type',
dataIndex: 'properties["Applicants.SecondaryType"]',
type: 'text',
},
$secondaryName: {
label: 'Name',
dataIndex: 'properties["Applicants.SecondaryName"]',
type: 'text',
},
$secondaryEmail: {
label: 'Email',
dataIndex: 'properties["Applicants.SecondaryEmail"]',
type: 'text',
},
$secondarySSN: {
label: 'SSN',
dataIndex: 'properties["Applicants.SecondarySSN"]',
type: 'text',
},
...
},
...
}
Example - Custom Cards config
{
...
customCards: [
{
label: 'Primary',
icon: 'PermIdentityTwoTone',
type: 'list',
properties: [
'$primaryType',
'$primaryEmail',
'$primaryEmail',
'$primarySSN',
],
},
{
label: 'Secondary',
icon: 'PermIdentityTwoTone',
type: 'list',
properties: [
'$secondaryType',
'$secondaryName',
'$secondaryEmail',
'$secondarySSN',
],
},
],
...
}

This example can become complex when adding more applicant properties on the Txn properties, but this can be improved by changing the way we store the Applicants information into a single JSON property.

Refactored Txn properties
{
"Applicants": "[{\"type\":\"Primary\",\"email\":\"[email protected]\",\"name\":\"David Gilmore\",\"ssn\":\"122-313-3443\"},{\"type\":\"Secondary\",\"email\":\"[email protected]\",\"name\":\"Matt Green\",\"ssn\":\"111-233-1234\"}]"
}

Using the dataSource attribute, we can tell Workspaces to look for child attributes inside a JSON property in the Txn.

Refactored Global Mappings config
{
...
mappings: {
...
$applicants: {
label: 'Applicants',
icon: 'PermIdentityTwoTone',
type: 'tableExtended',
dataSource: 'properties["Applicants"]',
properties: [
{
label: 'Role',
dataIndex: 'type',
type: 'text',
},
{
label: 'Name',
dataIndex: 'name',
type: 'text',
},
{
label: 'Email',
dataIndex: 'email',
type: 'text',
}
],
sections: [
{
label: 'Personal Info',
type: 'list',
properties: [
{
label: 'Name',
dataIndex: 'name',
type: 'text',
fullWidth: true,
},
{
label: 'SSN',
dataIndex: 'ssn',
type: 'text',
},
{
label: 'Email',
dataIndex: 'email',
type: 'text',
},
],
},
],
},
...
},
...
Refactored Applicants config
{
...
customCards: ['$applicants'],
...
}

This example demonstrates how the tableExtended custom card (introduced in Workspaces 19.11) can be used to simplify mappings configuration and group values in a single Txn property.