Page 1 of 1

3 tables linking problem

PostPosted: Wed May 27, 2009 7:51 am
by brokenclock
Hi,

It's been a long time that I did not play with Xataface, and I am still a newby at it. So, please, excuse-me if my question seems dumb.
I've have 3 tables : clients, contacts, actions.
actions and contacts have a client_id field pointing to the id field of the client table, defined in fields.ini and valuelists.ini files.
I defined a relationships.ini in the clients directory. So I have the 2 great tabs in the clients page.
But i also have an contact_id field on the actions table, pointing to contact.id, defined in fields.ini and valuelists.ini files.
Great.
When I use the actions tab of the clients page to add a new action, I see a select field with ALL my contacts.
The problem is that I only want to see the contacts with the field client.id set to the current client.

How can I do that?

Best regards,

BrokenClock

PostPosted: Tue Jun 02, 2009 1:19 am
by silma
Hello,

Maybe the valuelist function could help you ?

http://xataface.com/forum/viewtopic.php?t=3961

Re: 3 tables linking problem

PostPosted: Tue Jun 02, 2009 10:22 am
by shannah
brokenclock wrote:Hi,

It's been a long time that I did not play with Xataface, and I am still a newby at it. So, please, excuse-me if my question seems dumb.
I've have 3 tables : clients, contacts, actions.
actions and contacts have a client_id field pointing to the id field of the client table, defined in fields.ini and valuelists.ini files.
I defined a relationships.ini in the clients directory. So I have the 2 great tabs in the clients page.
But i also have an contact_id field on the actions table, pointing to contact.id, defined in fields.ini and valuelists.ini files.
Great.
When I use the actions tab of the clients page to add a new action, I see a select field with ALL my contacts.
The problem is that I only want to see the contacts with the field client.id set to the current client.

How can I do that?

Best regards,

BrokenClock



Can you post your relationships.ini file. There is likely a problem with the definition of your actions relationship.[/url]

relationship.ini

PostPosted: Tue Jun 02, 2009 11:54 am
by brokenclock
here clients/relationship.ini
Code: Select all
[contacts]
contacts.client_id = clients.id
[actions]
log.client_id = clients.id

Hope this help!

PostPosted: Tue Jun 02, 2009 12:55 pm
by shannah
Change it to:
Code: Select all
[contacts]
contacts.client_id = "$id"
[actions]
log.client_id = "$id"

Same thing

PostPosted: Wed Jun 03, 2009 1:02 am
by brokenclock
I tried, but things remain the same.
I think that part of the problem stands in the log/valuelists.ini, I did not know how to set the vocabulary to get the corresponding contacts. Currently, it is:
Code: Select all
[contact]
__sql__  = "SELECT id, nom FROM contacts"

which works fine when you want to add an action from the action tab and you do now have any client selected.
I've tried many times to set it differently to get only the client's contacts when there is a client selected, but dit not find the correct way. For example:
Code: Select all
[contact]
__sql__  = "SELECT id, nom, client_id FROM contacts WHERE client_id = '$id'"

Should I use the valuelist function as silma suggests?[/code]