Hi, I need to increase offset +100 and so on few times… It increases for me only once from zero to 100 and stays like that, what is wrong
$node["Set Offset"].json["offset"] += 100;
return {offset : $node["Set Offset"].json["offset"]};
Hi, I need to increase offset +100 and so on few times… It increases for me only once from zero to 100 and stays like that, what is wrong
$node["Set Offset"].json["offset"] += 100;
return {offset : $node["Set Offset"].json["offset"]};
Hello @milica , I’ve had a similar use case, but for do that I had to use a thrith part database, like Google sheet or baserow.
So save the number there and get when u want to increase, and then save it again
Hmm, should it be other way to do that, like this logic?
I’ve created this topic few times ago, give it a chance to see if fit with your use case:
Hi @milica, if you don’t need to persist your offset across different executions you could try this approach:
In this example I am using the $itemIndex
variable (and multiply it by 100) which n8n provides. So for the first item the resulting offset is 0, for the second item it’s 100, for the 3rd it’s 200 and so on:
etc
If you have to use a loop, you could alternatively use $runIndex
instead. These variables are documented over here.
Hope this helps
I solved like this, I used $runIndex
$node["Set Offset"].json["offset"] =($runIndex+1) * 100;
return {offset : $node["Set Offset"].json["offset"]};
@Gabriele_Bracciali @MutedJam I solved like this, I used $runIndex
$node["Set Offset"].json["offset"] =($runIndex+1) * 100;
return {offset : $node["Set Offset"].json["offset"]};
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.