Jsonpath - how to use parameters or variables inside a jsonpath

Using jsonpath as the expression in a mapper snap the following works:

jsonPath($, “$entity.items[?(@.AssignmentNumber==‘E3163300-2’)].links[*]”).find(x=>x.name == ‘assignedPayrolls’).href

I want to pass in the assignment number from a parameter but this doesn’t seem to work:

jsonPath($, “$entity.items[?(@.AssignmentNumber==’_AssignmentNumber)].links[*]”).find(x=>x.name == ‘assignedPayrolls’).href

This is with parameter _AssignmentNumber set to the value that works which is ‘E3163300-2’

How can I get jsonpath to work with parameters or variables?

Hi @swright,

You need to concatenate the jsonPath with the pipeline parameter.

jsonPath($, "$entity.items[?(value.AssignmentNumber=='" + _AssignmentNumber + "')].links[*]").find(x=>x.name == "assignedPayrolls").href

Thank you! Your solution worked perfectly! I had tried something like that before and it failed. It was probably my syntax but your syntax worked on the first try!