HELP - Value defined in the Code and one cancels the other

I want to put the ARTICLE and the FAQ in Code 1, but the “Value” of the FAQ is the same as the ARTICLE, then in the code of Code1 it is overwriting the ARTICLE and only the FAQ appears.

Hey @Edgard_Neto,

If you look at your input on the left there is no chapterText only chapterText2 this is why in your output you have undefined after the first 2 <br><br>

Based on your screenshot it doesn’t look like anything is being written and it is working as expected based on the data the node has been given.

It might be worth going back through your workflow execution log to work out where chapterText is being lost.

The print was with the Faq screen, but it was supposed to show this one, see the article screen below. And the “chapterText” markup as I had said in the message above.

Hey @Edgard_Neto,

If you look at the screenshot you shared there is no value for chapterText on the input item to the code but there is a chapterText2. When you use $input.all() it uses all of the input items that directly lead into the node this does not include nodes that are further back in your workflow.

The issue you have here is in your Set node (Set3) you have told it not to keep any other data so it removing the other items from the Merge node, You can see this in the image below.

image

the “Set3” is getting only the “OpenAI2” from the Faq.

the “Set2” that is not working, to get the data from “OpenAI1”.

@Jon

@Edgard_Neto,

If you are using $input.all() in the code node it will only use the information from the node directly before it, So with your workflow it doesn’t matter what is in Set2 or the Merge node because the only data it is going to see when using $input.all() is the data which is coming out of “Set3” which is why it is only able to use item.json.chapterText2.

You can use data from other nodes like you have with the first line by using $('Set1').first().json.title but this is only going to use the first item from the “Set1” node.

What I would do instead is something like the below which seems to result in the data being outputted although the content is still in JSON and will need to be parsed.

@Jon

I put a “set” node with data to clear the lines in JSON, but it didn’t work.

What do I put to clean these lines in “JSON” and only the article appears.

Sorry for so many messages, I’m a beginner.

Hey @Edgard_Neto,

You would need to use a code node or a set node to parse the json to give you the fields you want, That is assuming you even want to work with JSON when you could probably ask OpenAI to give you the data in an HTML format ready to go.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.