Forum Discussion
2 Replies
- tstackFormer Employee
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:
eval(_field1)
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(doc.fieldValues.map (elem => [elem.id, elem.type, elem.value])) }
You can then execute that function in your mapper with an expression like this:
lib.mylib.extract($)
- dmillerFormer Employee
See this thread: Pipeline parameters
- jhagistNew Contributor III
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
- brianrandolphNew Contributor III
you shouldn’t need parenthesis around the name. “_field1” should work.
- jhagistNew Contributor III
When I try it without the parenthesis around the name. “_field1” All I get is the parameter as a string.
Snap,
Any ideas??
- jhagistNew Contributor III
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! 😀