I have a slightly nested function that will run as soon as the user presses "save".
To keep it short, the function has to call delegates (using context.executeQueryAsync) twice.
The first time calling executeQueryAsync it runs fine, the second time the forms submits the data without waiting for anything to actually finish/be loaded.
To better explain: I need to retrieve a number of ListItems using the RelatedItems field and then Loop through those and Approve those - Resulting in 2 executeAsyncQueries, one of which is in a for loop.
How can I manage this?