The problem I’m facing is that the blocks sometimes work fine and update the desired row , but at other times it updates the wrong row like updating the header.
The set app variable block is going to trigger before the new row is created in your data source. It needs to be in the “do” section so that it happens after the row is created.