Dear all
I have been fighting a problem with my solution for 2 days. Someone please tell me where I’m screwing it up… It worked fine when I first made it, but it began failing with an error every now and again, and now it simply does not run at all…
I have a valuelist that is populated by this method:
function set_valuelists()
{
databaseManager.saveData()
var sql_query = "SELECT DISTINCT invoice_number_text, sales_id FROM line_items WHERE sales_id = " + forms.sale_master.salesid + "ORDER BY invoice_number_text asc";
var dataset = databaseManager.getDataSetByQuery(controller.getServerName(), sql_query, null, 300);
var maingroupArray = new Array();
var index = 0;
maingroupArray[0] = 'new invoice';
maingroupArray[1] = 'new credit';
var index = 2
for (var i = 0; i <= dataset.getMaxRowIndex(); i++)
{
dataset.rowIndex = i;
maingroupArray[index] = dataset.invoice_number_text;
index = index + 1;
}
application.setValueListItems('invoice_credit_chooser', maingroupArray);
}
This works fine, and gives me a dropdown with ‘new invoice’, new credit, and a list of all previous invoice numbers so that the current line can be applied to a previous invoice number. So far so good…
I then have a method to figure out what to do depending on the choice above. It goes like this:
function choose_invoice_credit()
{
if (invoice_number_text == 'new invoice')
{
var vnew_invoice_number = 6
//plugins.dialogs.showInputDialog('Invoice number','Please provide an invoice number');
if (vnew_invoice_number)
{
var sql_query = "SELECT invoice_number_text FROM line_items WHERE invoice_number_text = " + vnew_invoice_number;
var dataset = databaseManager.getDataSetByQuery(controller.getServerName(), sql_query , null,-1)
}
}
}
There will be more than that, but it fails at the var dataset point. The console error I get is: SQL Anywhere Error -157: Cannot convert new invoice to a numeric(30,6)
at /Applications/Servoy/servoy_workspace/interiors/forms/line_items_complex_master/line_items_complex_master_methods.js:1279 (choose_invoice_credit)
I don’t have anything called ‘new invoice’ apart from the text in the dropdown. The sql query is not setting anythingThe field behind the combobox is a text field, and has been populated by text and numbers.
I’m stumped. Someone please tell me what I’m doing wrong…
Thanks
Bevil