ok, not pretty but here is a way...
[{"id":"bec8666.4ca4798","type":"inject","z":"68fd4d54.10dd54","name":"fake data (1 match)","topic":"","payload":"{\"dboutput\":[{\"ID\":1,\"egyiknev\":\"a1\",\"masiknev\":\"a2\"},{\"ID\":2,\"egyiknev\":\"b1\",\"masiknev\":\"b2\"},{\"ID\":3,\"egyiknev\":\"c1\",\"masiknev\":\"c2\"}],\"xmloutput\":[{\"egyiknev\":\"a7\",\"masiknev\":\"a7\",\"alias\":\"a7\"},{\"egyiknev\":\"b8\",\"masiknev\":\"b8\",\"alias\":\"a8\"},{\"egyiknev\":\"c9\",\"masiknev\":\"c1\",\"alias\":\"c9\"}]}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":630,"y":160,"wires":[["a3f3b8c6.d89278"]]},{"id":"a3f3b8c6.d89278","type":"function","z":"68fd4d54.10dd54","name":"cross search arrays","func":"var xmloutput = msg.payload.xmloutput;\nvar dboutput = msg.payload.dboutput;\nvar found = null;\nfor (let i = 0; i < xmloutput.length; i++) {\n const d = dboutput[i];\n for (let j = 0; j < dboutput.length; j++) { \n const x = xmloutput[j]; \n if(\n d.egyiknev == x.egyiknev ||\n d.egyiknev == x.masiknev ||\n d.egyiknev == x.alias ||\n d.masiknev == x.egyiknev ||\n d.masiknev == x.masiknev ||\n d.masiknev == x.alias\n ){\n found = {d,x};\n break;\n }\n }\n if(found) break;\n}\nif(found){\n msg.payload = found;\n return [msg, null]\n} else {\n return [null, msg]\n}","outputs":2,"noerr":0,"x":850,"y":200,"wires":[["999e37d7.917cf8"],["7aee6f5c.e9f13"]]},{"id":"999e37d7.917cf8","type":"debug","z":"68fd4d54.10dd54","name":"found","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1070,"y":180,"wires":[]},{"id":"7aee6f5c.e9f13","type":"debug","z":"68fd4d54.10dd54","name":"not found","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1080,"y":240,"wires":[]},{"id":"81b5d98d.8b0828","type":"inject","z":"68fd4d54.10dd54","name":"fake data (0 match)","topic":"","payload":"{\"dboutput\":[{\"ID\":1,\"egyiknev\":\"a1\",\"masiknev\":\"a2\"},{\"ID\":2,\"egyiknev\":\"b1\",\"masiknev\":\"b2\"},{\"ID\":3,\"egyiknev\":\"c1\",\"masiknev\":\"c2\"}],\"xmloutput\":[{\"egyiknev\":\"a7\",\"masiknev\":\"a7\",\"alias\":\"a7\"},{\"egyiknev\":\"b8\",\"masiknev\":\"b8\",\"alias\":\"a8\"},{\"egyiknev\":\"c9\",\"masiknev\":\"c9\",\"alias\":\"c9\"}]}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":630,"y":240,"wires":[["a3f3b8c6.d89278"]]}]
Replace the fake inject with real data.
This simulation expects msg.payload to contain 2 properties that are the xmloutput
and the dboutput
arrays (but you can edit the top to lines of the function to suit)
var xmloutput = msg.payload.xmloutput; //change me to suit
var dboutput = msg.payload.dboutput; //change me to suit
NOTE:
- this solution does not handle un-trimmed strings or case differences (i.e. the values must match EXACTLY)
- this solution will stop and return after the first match found (will need modification if you want all matches)
- this solution expects you to use the payload returned and format in your email template accordingly