Expression to identify exact number only, not contains the number

I have an expression

csa_no:{{$node["Merge5"].json["Paddler 1 CSA"]}}

That fetches every record from mautic that has a “csa_no” that matches the “Paddler 1 CSA” number.

I am having an issue in that any record that contains the “Paddler 1 CSA” is fetched.

For example if the “Paddler 1 CSA” is 53, n8n is fetching every record that contains 53.
5367
53789
53678

And so on

Is there a way I can set the expression to only fetch the exact number (eg 53). The number could be 2, 3,4 or 5 digits.

Hey @Robm,

I suspect there is a bit more to this, The snippet you provided I would expect to do exactly what you have described as that snippet on its own doesn’t do any filtering it just grabs the value for that iteration.

What else are you doing in your workflow, I can see you are using a merge node but are you telling it to only look for 53 somewhere?

Internally n8n loops the data for most nodes so if you had 50 inputs the node would loop 50 times and process each record one by one and pass it to the next node so while the output may be showing multiple lines it will be one run for each of them.

Thank Jon,

This is a pretty complex flow and I am doing quite a bit. Essentially I am fetching data from database 1, doing some data manipulation, checking if it exists in database 2 by looking for email then csa_no and then either updating or creating the new record in database 2.

I am not telling to look only for 53 anywhere, but when I ask it to look for Paddler 1 CSA and the answer is 53 (currently that is the value that is causing this behaviour) then it returns all records with a csa_no that starts with 53. It does seem to be limited to the 1st 2 digits of the number sequence.

I am stumped as to why. Must csa_no’s are 3 or more digits. 53 is one of the few 2 digits numbers, perhaps that is involved? I think this will take a smarter person than I to look at the whole flow and spot the issue. The flow contains sensitive info so reluctant to post to an open forum

Hey @Robm,

Are you able to make a simpler flow that reproduces the issue?

Without seeing the data input and output it is hard to understand what you are seeing but if you are not filtering at all then I would say it is too be expected and maybe something needs to change in your workflow.

Found the issue and the solution. I was looking inside of mautic for the unique number (CSA). It seems by default that a search in mautic uses “include” ie it will return all results that include the search criteria. So if the CSA no is 53 it will return all results that contain 53.

Looking into mautuc documentation, if the add “+” in forn the of the numebr it will search just for the number so csa_no:+53 returns only 53.

For the expression it would be

csa_no:+{{$node["Merge5"].json["Paddler 1 CSA"]}}

That seems to have solved the issue.

1 Like