Unable to pass variable in another variable in code or set node
a=$(‘Set2’).all()
b=$(‘JSON validation’).all()
data=a[0][‘json’][‘Test’]
app_data=b[0][‘json’][“data”][“view”][“state”][“values”][‘Select $(data) text’]
return{“json”:{app_data}}
I am unable to fix this. couldn’t share the workflow here. Need help in fix the blow line in above code. Not sure on how to pass data variable in app_data variable. Didn’t receive any errors
app_data=b[0][‘json’][“data”][“view”][“state”][“values”][‘Select $(data) text’]
Hi @Ananth_Rayala,
one tip on how to debug a situation like this: you can use console.log() in the Code node and check the result in the browser inspector console.
Looking at your problems, it seems that [‘Select $(data) text’] is not doing what you would expect.
Two ways you can try:
["Select ' + data + ' text"]
- [
`Select ${data} text`] (Pay attention to use the backtick as suggested here)
I also attach here a workflow with a similar example:
Let me know if that help
Best
Thanks a lot @giulioandrein format with backtick worked.
a=$(‘Set2’).all()
b=$(‘JSON validation’).all()
data=a[0][‘json’][‘Test’]
app_data=b[0][‘json’]["data"]["view"]["state"]["values"][`Select ${data} text`]
return [
{
"app_data_1": app_data_1,
}
];