diff --git a/README.md b/README.md index 4944a02..878334b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -Adobe Launch - Mapping Table -============================ +# Adobe Launch - Mapping Table Provides a rich and versatile mapping table data element. @@ -21,6 +20,22 @@ JSON & CSV import and export supported directly from within the data element. If you are using the *regex with matching*, you can use the results of your matching groups in the output with the common syntax of `$1`, `$2`, etc. \ You cannot use the matching `$1`, etc. within a data element name in the output. e.g. `%my element $1%` is not supported and will throw an error upon saving the mapping table data element. +## Basic Usage: +Select a **Data Element** to be searched for matches - this can either be a single value such as `%pageName%` or an array, like `%productsInCart%`. + +When an array is given, each element of the array will be searched, and a corresponding mapping given, resulting in an output which is an array, of the same length as the input array. + +Click the `+` sign to add a mapping row. Order matters - higher rows will be considered first and the search for a match will end with the first successful match. You can drag and drop rows to change the order. + +Within each row choose: +- A **Method** - possible methods are mentioned above +- An **Input** - this is what you are looking to match within the Data Element. +- An **Output** - this is what you want to transform the Input into + +E.g. if the Method is "Contains", the Input is "meaning of life", the Output is "42", and the Data Element is "what is the answer to the meaning of life?" then the output will be "42" + +Check the **Default Value** at the top if you want to pass through the original value in the case that no match has been found. If unselected and no match is found, the output value will be `undefined`. + A **detailed walk through** of some use cases can be found in the [Tutorial PDF](doc/mapping-table-tutorial.pdf). @@ -28,4 +43,4 @@ Official implementation of https://www.adobeexchange.com/experiencecloud.details ------------------------------------------------------------------------------------------------------------------- -Please refer to the [Release Notes](ReleaseNotes.md) for an overview of what has changed in the respective version. \ No newline at end of file +Please refer to the [Release Notes](ReleaseNotes.md) for an overview of what has changed in the respective version. diff --git a/extension.json b/extension.json index e2478a3..3361c7b 100644 --- a/extension.json +++ b/extension.json @@ -2,7 +2,7 @@ "displayName": "Mapping Table", "name": "mapping-table", "platform": "web", - "version": "1.1.1", + "version": "1.1.2", "exchangeUrl": "https://www.adobeexchange.com/experiencecloud.details.103136.html", "description": "Provides a rich and versatile mapping table data element. Supports regex, exact and case insensitive matches, starts with, contains and boolean matching. Further the output can be static or another data element to offer even more flexibility. E.g. ideal for implementing multiple marketing pixels.", "author": { @@ -32,4 +32,4 @@ "viewPath": "dataElements/mappingTable.html" } ] -} +} \ No newline at end of file diff --git a/src/lib/dataElements/mappingTable.js b/src/lib/dataElements/mappingTable.js index 6cc2b40..ddffb8f 100644 --- a/src/lib/dataElements/mappingTable.js +++ b/src/lib/dataElements/mappingTable.js @@ -9,10 +9,8 @@ * @returns {*} */ module.exports = function (settings) { - if (typeof settings !== 'undefined' && settings !== null) { - var dataElemValue = settings.dataElement; - addStartsWithToIE(); + function checkValue(dataElemValue) { try { for (var i = 0; i < settings.size; i++) { var method = settings[i].method; @@ -84,6 +82,15 @@ module.exports = function (settings) { } return dataElemValue; } + + if (typeof settings !== 'undefined' && settings !== null) { + var dataElemValue = settings.dataElement; + addStartsWithToIE(); + if (typeof dataElemValue !== 'undefined' && dataElemValue !== null && Array.isArray(dataElemValue)) { + return dataElemValue.map(checkValue); + } + return checkValue(dataElemValue); + } }; /** @@ -96,5 +103,4 @@ var addStartsWithToIE = function () { return this.substr(position, searchString.length) === searchString; }; } -}; - +}; \ No newline at end of file diff --git a/src/view/configuration/configuration.html b/src/view/configuration/configuration.html index 30a2c69..7b9594a 100644 --- a/src/view/configuration/configuration.html +++ b/src/view/configuration/configuration.html @@ -37,7 +37,27 @@

Mapping Table

common syntax of $1, $2, etc.
You cannot use the matching $1, etc. within a data element name in the output. e.g. %my element $1% is not supported and will throw an error upon saving the mapping table data element.

+

+ +

Basic Usage

+

Select a Data Element to be searched for matches - this can either be a single value such as %pageName% or an array, like %productsInCart%.

+ +

When an array is given, each element of the array will be searched, and a corresponding mapping given, resulting in an output which is an array, of the same length as the input array.

+ +

Click the + sign to add a mapping row. Order matters - higher rows will be considered first and the search for a match will end with the first successful match. You can drag and drop rows to change the order.

+ +

Within each row choose:

+ + +

E.g. if the Method is "Contains", the Input is "meaning of life", the Output is "42", and the Data Element is "what is the answer to the meaning of life?" then the output will be "42"

+

Check the Default Value at the top if you want to pass through the original value in the case that no match has been found. If unselected and no match is found, the output value will be undefined.

+ +

A detailed walk through of some use cases can be found in the Tutorial PDF. @@ -67,4 +87,4 @@

Mapping Table

}); - + \ No newline at end of file