Dynamic Field Extension

Contributed by @cjhoward18


This pipeline pattern helps dynamically create fields from a series of field value pairs in a string.

The CSV Generator creates sample content as follows:

field1
a=1&b=2&c=3

We want to separate the entries at the ampersands, with the letters being the key and the numbers being the associated value.

In the Mapper, the expression to split the data into key value pairs is as follows:

$.extend($.field1.split("&").map(keyVal => keyVal.split("=")).map( val => {[val[0]]: val[1]}).reduce((accum, curr) => curr.merge(accum), {}))

The result data looks like this:

โ€œfield1โ€: โ€œa=1&b=2&c=3โ€
โ€œcโ€: โ€œ3โ€
โ€œbโ€: โ€œ2โ€
โ€œaโ€: โ€œ1โ€

Source: series of field value pair strings
Target: Dynamic Fields
Snaps Used: CSV Gererator, Mapper

Downloads

Dynamic Field Extension.slp (3.2 KB)

1 Like