I have an Invoice form (Invoice_Master) which lists Invoices and Payments in a Tabpanel from a related table (Invoice_Payments) based on the Invoice Number.
I have a pop menu located within each row which provides a “Payment” option to create a payment for a specific invoice.
The code is:
//get info from selected invoice
var invoice = invoice_number;
var patient = patient_id;
This all works fine. The problem is that I would like to request focus on the new entry but Servoy always goes to the first row rather than the new row. I have tried several variations of getSelectedIndex, setSelectedIndex but I can’t make it work.
It looks as if your sorting at the end makes it a bit difficult to identify the row you want to go to. In my eyes, sorting at this point is also a bit confusing. As a user I would expect the new record to be at the end of beginning of the list and not being sorted somewhere.
But, your problem of selecting the newly created record should be solvable if you change your code for example to this
//get info from selected invoice
var invoice = invoice_number;
var patient = patient_id;
//create new record
var vNewRecord = foundset.getRecord(foundset.newRecord());
//enter payment data
vNewRecord.invoice_number = invoice;
vNewRecord.patient_id = patient;
vNewRecord.entry_type = 'payment';
var date = application.getTimeStamp();
date.setHours(0,0,0,0);
vNewRecord.invoice_date = date;
controller.sort('invoice_number asc, invoice_date asc');
foundset.selectRecord(vNewRecord.primaryKeyColumn);
Thanks for your response. The reason for the sort after the new record creation (payment) is to place the payment directly beneath the selected invoice in the list. Initially the records are listed sorted by Invoice number followed by the payments attached to each invoice. It is unlikely that an invoice receiving a payment is either at the beginning or end of the list but rather in the middle. The sort places the new payment directly beneath the appropriate invoice. However, I then lose its specific row placement.
I made the code change suggested but unfortunately it did not resolve the issue. The active record remains the first record after the method runs.
I cancelled that method after your comment to see if it had an effect and it did not.
The funny thing is that everything works perfectly except the active row always goes to the first row. If I have a list of 100 Invoices it would become annoying to have to scroll to the middle of the list every time you enter a new payment. I’m sure there is a simple solution, I just can’t find it yet. Thanks