on 06-15-2017 4:41 PM
I'm following the this example to retrieve data from the back-end using xsjs but when I run my app I get an empty array as a result and can't figure out why.
example I'm using: XSJS example
here is my code:
var select_all_sales_orders_query = "SELECT * FROM \"_SYS_BIC\".\"MYPATH/CALCULATION\" (\'PLACEHOLDER\'=(\'$IP\', '34963'))";
function close(closables) {
var closable; var i; for (i = 0; i < closables.length; i++) {
closable = closables[i]; if(closable) { closable.close(); }
} }
function getSalesOrders(){
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 salesOrder;
while (resultSet.next()) {
salesOrder = {};
salesOrder.CAGE = resultSet.getString(1); } }
finally {
close([resultSet, statement, connection]); }
return salesOrdersList; }
function doGet() {
try{
$.response.contentType = "application/json";
$.response.setBody(JSON.stringify(getSalesOrders()));
} catch(err){
$.response.contentType = "text/plain";
$.response.setBody("Error while executing query: [" + err.message + "]"); $.response.returnCode = 200; } } doGet();
I'm trying to retrieve a single column for now to test it but the result is simple this '[]'. I'm new to XSJS so I don't know how to debug it. I tried using $.trace.debug('message'); but this doesn't print anything on the console. Can someone show me how to debug this or shine some light on what I'm doing wrong?
The way you address the parameter of your calc view is incorrect. Instead of '\n$IP' it must be '\n$$IP$$' (if the parameter name is IP).
Regarding the debugging question, you can do a search here or in the official documentation. There are already many posts available. If you are working with the web-based dev workbench it is pretty easy. A search in the documentation would produce a result like Tutorial: Create and Debug a Server-side JavaScript Application.
Regards,
Florian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.