Problem with Pipeline Parameter in Mapper Snap

I am using a mapper snap to extract data from a json schema. This is the code from the expression

{id:id}.extend( (elem => [, elem.type, elem.value]))

What I want to do is place this in a pipeline parameter (so can change this equation from the config file).

I can’t figure out the expression syntax. Here is a screenshot of my latest failure. :slightly_frowning_face:

See this thread: Pipeline parameters

Thanks for this. I am currently using the pipeline parameter to pass this information.

My question is really how to write the syntax.

I have put the function (that I need to variablize) into the Pipeline parameter _field1 but I can’t get it to run

you shouldn’t need parenthesis around the name. “_field1” should work.

When I try it without the parenthesis around the name. “_field1” All I get is the parameter as a string.


Any ideas??

Have you tried putting it in an expression library and then reference it there?

For example, I have an expression library file invItems.expr:
INVOICE_TARGET_DATE: _invoice_date ||’{“timeZone”:“EST”, “format”:“yyyy-MM-01”}’)

and then i reference that in the pipeline:


As you found out later, the value of a pipeline parameters is a string. In order to evaluate it, you’ll need to use the ‘eval()’ function, like so:


Alternatively, you can put the expression in a file and import that file as a library (see Expression Library). Your library file would contain an object with a field that contains your function, like so:

    extract: doc => {id:id}.extend( (elem => [, elem.type, elem.value]))

You can then execute that function in your mapper with an expression like this:

1 Like

Awesome that worked!

I did not try the library but it is an interesting concept.

Personal note for anyone else struggling with this. I am would suggest using the library suggestion or a parameter for the entire function. I spent a ton of time trying to variablize out the function and this path is much easier.

Another point. You can’t use a variable with the json schemas in a mapper, it has to be a parameter.

Hope this helps! :grinning: