Describe the issue/error/question
Function Intem node using a variable result in another variable
I am trying to find one vlue and then use it in a lookup. I however do not get the return due to the
vriable in the second var. Below the 1st variable tet2 returns 735 correct and the second variable with the “735” hardcoded works fine.
var test2 = $item("0").$node["SplitInBatches"].json["user"]["organisation_id"]
var test = $item("0").$node["Organisations"].json["data"].find(field => field.id == "735").value;
item.organisationname = test
return item;
However when I replace the hardcoded “735” with the test2 variable it does not work. and I get Unexpected identifier [Line 109 | Item Index: 0]
var test2 = $item("0").$node["SplitInBatches"].json["user"]["organisation_id"]
var test = $item("0").$node["Organisations"].json["data"].find(field => field.id == '"'test2'"').value;
item.organisationname = test
return item;
I have tried the ‘"test’"’ in various ways but im unable to make it work. It probably is just something small but being a non developer I am stumped.
Hi @mvandyk, the .find(field => field.id == '"'test2'"')
part looks odd to me. Seeing you are trying to compare the value of field.id
with the value of test2
, can you try using .find(field => field.id == test2)
instead?
Hi thank you for the reply.
Just .find(field => field.id == test2) does not work, it seems to want the “test2” but I dont know how to formulate the string for it. If I just put .find(field => field.id == 735) for instance it also fails.
Any chance you can you share your workflow including some example data so I can run it on my side and take a closer look?
I will yes, I however have a custom node in there I need to just start with the data.
Apologies " should be ’
I started with this item.myText = item.customFieldItems.find(field => field.idCustomField == ‘61767b5b71d35f8b909bcdfe’).value;
That I found in Search function for specific custom fields in Trello cards - #3 by MutedJam
return item;
Got it working with your suggestion above.
Problem was however not the variable but the .value . It should have been .name.
Thanks just being able to rant sometimes help to find the answer (or mistake )
1 Like
Sweet, glad to hear this is now working. Thx for confirming
FYI I got it going with a double .find
var test2 = $item(“0”).$node[“SplitInBatches”].json[“customfields”].find(field => field.field_id == 219).value;
var test = $item(“0”).$node[“Customfields”].json[“data”].find(field => field.id == 219)[“options”].find(field => field.id == test2).value;
item.result = test
return item;