another load records by query problem

I have a form, client_employees, which I want to display in a popup form and limit it with only the client_employees of the current selected client on the client form.

In code I create the query and then use loadrecords to open the form with just the records I want showing.

The problem is when the form opens the right number of records have been selected, but both fields are blank and when I try to click into either field I get a “No record. Create one first.” message.

I have examined the SQL that the query is using and it is getting the right values.

Here is a copy of the code:

var myClient = forms.clients.id_clients
var query = 'SELECT client_employees.id_people, client_employees.id_t_client_employees FROM client_employees WHERE client_employees.id_client = ' +  myClient + ' order by client_employees.id_people, client_employees.id_t_client_employees';
application.output(query)
forms.client_employees.controller.loadRecords(query)
application.showFormInDialog(forms.client_employees,-1,-1,-1,-1, " Employees of " + globals.GetValueListValue("Clients", myClient))

What am I doing wrong???

gstein:
…The problem is when the form opens the right number of records have been selected…

Some questions:

  1. how could you see the right number of records?
  2. is the form you want to show in record view? (does it show records in listview)
  3. is there an error in .log.txt?

<1) how could you see the right number of records? >

I can see I have the right number of records from the query because I can do: application.output(query) and check the query in Interactive Sql. Plus, when the form opens, I do see the right number of records on the form, but the values are empty and I can’t edit it.

<2) is the form you want to show in record view? (does it show records in listview) >

The form is in listview. If I open it without using loadRecords it works fine.

<3) is there an error in .log.txt?>

No

2 more questions,

  1. the columns you select are both pks?
  2. are you running Servoy 2.1.1?

<the columns you select are both pks? >

No. id_people is part of the pk but id_t_client_employees isn’t, but I need to select them both becuase I need them both on the form.

<are you running Servoy 2.1.1?>

Yes.

gstein:
<the columns you select are both pks? >
No. id_people is part of the pk but id_t_client_employees isn’t, but I need to select them both becuase I need them both on the form.

ah, thats the problem… the docs/sample clearly states do “only” select the pk…! after that a Servoy form will just work as use without a query (i.e. all the fields will be accesseble)