Hello all.
I have a method which used to work perfectly. I cannot fathom now why it doesn’t. I think that a servoy update has possibly deprecated something, but I cannot find what it is.
I cannot debug it because debug does not work if there are rtf fields in a table view - which I have.
My method is supposed to add 10 to estimate_item_id (a number) depending on what the highest number is. Simple.
I have tried estimate_item_id = vthehighestvaluenumber + 10 as
estimate_item_id = utils.stringToNumber(vthehighestvalue + 10) but the result (if the highest value is 60) is 10.16 - I don’t understand what it is doing.
Very annoying as this used to work perfectly. Now it just gives every line the number 10.
My method is:
function new_line_using_group()
{
var sql_query = "SELECT MAX(estimate_item_id) FROM line_items WHERE line_items.sales_id = " + forms.sale_master.salesid + " AND line_items.main_group = " + "'" + globals.g_main_group + "'" + " AND line_items.hidden_from_estimate != 1"
var vthehighestvalue = databaseManager.getDataSetByQuery(controller.getServerName(), sql_query, null, 1);
var vthehighestvaluenumber = utils.stringToNumber(vthehighestvalue)
if (globals.g_main_group == 'new group')
{
var vmaingroup = plugins.dialogs.showInputDialog('Create a group', 'Please create a group for this item (eg. Master bedroom, Delivery lines etc.)','type here')
controller.newRecord(false,true)
main_group = vmaingroup
sales_id = forms.sale_master.salesid
contacts_id = forms.sale_master.contacts_id
estimate_item_id = 10
databaseManager.saveData()
elements.description.requestFocus()
}
else if (globals.g_main_group == 'all groups')
{
var thePressedButton = plugins.dialogs.showErrorDialog('No group', 'Please create or choose a group before adding a line','OK');
return
}
else
{
controller.newRecord(false,true)
main_group = globals.g_main_group
sales_id = forms.sale_master.salesid
contacts_id = forms.sale_master.contacts_id
if (vthehighestvalue)
{
estimate_item_id = vthehighestvaluenumber + 10
}
else
{
estimate_item_id = 10
}
databaseManager.saveData()
elements.description.requestFocus()
}
//open the item editor immediately
edit_item();
}
Any help would be appreciated
Bevil