Skip to Content
avatar image
Former Member

is possible to make calls in parallel(asynchronous) in XSJS?

Let's say I'm making a call to a calculation view using XSJS and I need to make a call to that calc view several times. Currently I'm making the calls in series one after the other. Is there a way to make all the calls at once in parallel.

Sample code of what I'm trying to achieve:

function getSalesOrders(IP, DATE){ 

//var IP = "1852";
//var DATE = "201410";

var select_all_sales_orders_query = "SELECT * FROM 
\"_SYS_BIC\".\"PATH_TO_CALCVIEW/CALCVIEW\"('PLACEHOLDER' =  
('$$IP$$', '"+IP+"'), 'PLACEHOLDER' = ('$$DATE$$', '"+DATE+"'))";


var salesOrdersList = []; var connection = $.db.getConnection(); 

var statement = null; var resultSet = null; try{ 

statement = connection.prepareStatement(select_all_sales_orders_query); 
resultSet = statement.executeQuery(); 

var salesOrderList = [];

while (resultSet.next()) { 

    salesOrder = {}; 

  salesOrder.CAGE = resultSet.getString(1); 

salesOrderList.push(salesOrder);} 

} 


 return salesOrdersList; 

} 

 function doGet() { 


for(var i=0; i<inputs.length; i++){
    getSalesOrders(inputs[i].IP, inputs[i].DATE); 
  }
} 


//get data from table here as an array and assign it to inputs[] array
doGet();

Is there a way to replace the for loop with something that would make all those calls asynchronously? My guess is that XS doesn't allow that but I would like to confirm. I'm using XS classic by the way.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers