(function executeQuery(v_table, v_query) { try { // get the REST message var message = new sn_ws.RESTMessageV2('x_12270_remote_tab.my users', 'Get'); // execute it var response = message.execute(); // get the response var responseBody = response.getBody(); var httpStatus = response.getStatusCode(); // if there is an error, log and return if (response.haveError()) { v_query.setLastErrorMessage(response.getErrorMessage()); gs.addErrorMessage(response.getErrorMessage()); return ; } // Parse response var json = new global.JSON(); var responseObj = json.decode(responseBody); var resultArr = responseObj.result; // all the records are contained in an array 'result' for (var i=0; i< resultArr.length; i++){ //build the row var row = {}; // map fields from the result row.first_name = resultArr[i].first_name; row.last_name = resultArr[i].last_name; row.active = resultArr[i].active; row.email = resultArr[i].email; row.phone = resultArr[i].phone; row.company = resultArr[i].company.value; // add the row to the remote table v_table.addRow(row); } } catch(ex) { v_query.setLastErrorMessage(ex.message); gs.addErrorMessage(JSON.stringify(ex)); } })(v_table, v_query);