Unable to populate Table data

Hi All,
My JS code structure looks something like below
Line 1: var myglobal = [];
Line 2: dbCall1
Line 3: onsuccess dbCall2
Line 4: …
Line 5: once all the data is fetched push the required data to myglobal
Line 6: return myglobal
Now since all the db calls
for example :-
additionalScope: {
data: productId
onSuccess: function(prod) {
are asynchronous Line 6 gets executed before any of the data is fetched. And table data is blank. Please help.

I think you’ll need to chain each dbcall inside the onSuccess function of the previous query. Try creating the myglobal value inside the onSuccess function of the final dbCall query, and then set the value of a Temporary State to myglobal. That should structure it so that you trigger dbCall1, then dbCall2, then create the myglobal value, and then set the temporary state value. Set the table to display tempStateName.value rather than JSQuery.data.

dbCall1.trigger({ onSuccess: function(dbOne) { dbCall2.trigger({ onSuccess: function(dbTwo) { //create myglobal from dbOne data and dbTwo data tempStateName.setValue(myglobal); }}}});

Passing data through multiple levels of onSuccess triggers can get tricky, but this should get you in the right direction