Function code for new record

Hi,
WOULD LIKE TO PASS A VARIABLE THAT ALWAYS CHANGES AND HAVE RECORDS AND NOT FIELDS AS PHOTOS
THANK YOU

Hey @marconte!

Good to see you back!

Can you please provide more details? Do you want to reference values from another node and use it in the Function node?

I am changing this to a Question for now. Please feel free to change it back to a Feature Request, if you want us to add a missing feature :slight_smile:

1 Like

I want pass reference values fron other node by function to other function which creates me records for each variable; my string that is passed through split always changes, so it would produce one or many records depends on the splitted variables

first function pass this:

const parts = item.myvar.split('_');
for (let i=0;i<parts.length;i++) {
  item[`var${i+1}`] = parts[i];
}

return item;

this is code wich obtain only one record i want myvar(var1,var2,ecc) as record

const newItems = [];
const json=$node["Function13"].data;
//'[{"id":"10"},{"id":"42"}]';
//$node["FunctionItem1"].data;
//'[{"id":"10"},{"id":"42"}]'
var obj;
var result;
var myvar;

obj = JSON.stringify(json);
//JSON.stringify($node["Function6"].data
//const obj2= JSON.parse(obj);
//const spl=obj.split('"\"');
//items[0].json=obj;

items[0].json.myvar=JSON.parse(obj);
return items;




for (const item of items[0].json.myvar) {
  newItems.push({json: item});
}

return newItems;
![bb|689x300](upload://xj8UGP9UvgxEaqHWVUHngCs2CDL.png)

Solved by myself:

var item=[];
var myvar = "az_az_az";
var parts=myvar.split('_');
var ok;

const newItems = [];
const newItems2 = [];

for (let i=0;i<parts.length;i++) {
  item[`var${i+1}`] = parts[i];
  ok=items[0].json = {data:  [ {"data": parts[i]} ]};
  for (const item of ok.data) {
  newItems2.push({json: item});
}

}



 


return newItems2;