How to reference Set Node in JSON.stringify

I am importing some contact info into our system via a set node and HTTP Post Node. The set node has two parameters, one specifies a base url and the other specifies an id. This data gets added as hyperlinks to the details of the contact in our system. If there isn’t a node reference, then using this works just fine:

[{"details_html":{{JSON.stringify('<p><a href="">Link to contact website</a></p><br><p><a href="">Link to contact details</a></p>')}}}]

However, if I use a reference, say to a Set Node, it looks like this:

[{"details_html":{{JSON.stringify('<p><a href="">Link to website</a></p><br><p><a href="$node["Contact Info"].json["base_url"]$node["Contact Info"].json["id"]">Link to contact details</a></p>')}}}]
[{"details_html":"<p><a href=\"\">Link to website</a></p><br><p><a href=\"$node[\"Contact Info\"].json[\"base_url\"]$node[\"Contact Info\"].json[\"id\"]\">Link to contact details</a></p>"}]

So what happens is the Link to contact details hyperlink is “$node…” instead of the valid hyperlink. I’m sure this is something simple I’m forgetting to do. Workflow code here:

Hi @jhambach, you are using $node["Contact Info"].json["base_url"]$node["Contact Info"].json["id"] inside a string marked by single quotes ' which is why it wouldn’t be evaluated.

A simple approach to get this working would be the plus operator + used to concatenate strings. This would be explained here. Your expression would then look like so:

[{"details_html":{{JSON.stringify('<p><a href="">Link to website</a></p><br><p><a href="' + $node["Contact Info"].json["base_url"] + $node["Contact Info"].json["id"] + '">Link to contact details</a></p>')}}}]
Example Workflow
1 Like

That did the trick, thank you so much @MutedJam!

1 Like