Use array to change field name

Hello,
I wish to get some help on my problem.

I get from my “inDataHub” node a flow of items with this kind of field:

{"FI33574732": "DropDown", "FI33574733": "Hardware | WiFi | Conferencing tool | Chat tool | Printer | Ethernet (cable network) | Company website | VPN | Intranet | Billing services | Finance services | Data Center | Other", "FI33595652": "CENTRE D'AIDE", "FI33595802": "IEADH733JUAEGCDA"}

and from the “edit field”, i get inly one item:

[{"isMirror": false, "id": "FI33574732", "title": "Type", "type": "text", "readerIds": []}, {"isMirror": false, "id": "FI33574733", "title": "Description", "type": "text", "readerIds": []}, {"isMirror": false, "id": "FI33595652", "title": "Emplacement", "type": "text", "readerIds": []}, {"isMirror": false, "id": "FI33595802", "title": "wrikeID", "type": "text", "readerIds": []}]

I need to edit each item from the first flow so in the json, the four values are changed with the title of the corresponding id from the second node.

It should be looking like this at the end:

{"Type": "DropDown", "Description": "Hardware | WiFi | Conferencing tool | Chat tool | Printer | Ethernet (cable network) | Company website | VPN | Intranet | Billing services | Finance services | Data Center | Other", "Emplacement": "CENTRE D'AIDE", "wrikeID": "IEADH733JUAEGCDA"}

I think we can’t do this kind of edit with only standards nodes like merge

I tried with the code node but with the two inputs and the wierd way n8n is allowing to use the inputs, I failed to do the edit. can someone help me please?

Thanks all

1 Like

Try to SplitOut outputs in both flows (from inDataHub field in the first and from body.fieldsInfo field in the second one) and then Merge two data flows by id.

If this doesn’t work then please re-post the workflow with data pinned in Set nodes. It’s much easier to test suggestions having data at hand than trying to “compile” quoted JSONs, esp. those put in a single line.

If it does though, then please mark this post as a :white_check_mark: Solution.

Hey, Thank you for your reply.

The issue here is that in the datahub flow, the ids are the keys, when in the field block, the ids are the values…

Here is the pinned flow:

Thanks

This is one messed data structure. The other problem is that inputs were not fully parsed.

I hoped it could be achieved in n8n way, but finally gave up and put a Code node for final transformation.

This probably all could be put in a single Code node.

I also very likely, along the course had to reconstruct the initial input as it was not available.

Check the Code node pinned output. If this is what you need then here you are. I will leave optimizations to you tho.

If this resolves your question please mark this post as a :white_check_mark: Solution.

2 Likes