Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

lookup object don't display other fields

Post Reply
massiws
Posts: 503
Joined: Thu May 24, 2012 2:08 am
Location: Milan, Italy
Contact:

lookup object don't display other fields

Unread post by massiws »

Sorry, maybe a stupid question.
I have a lookup object on my form and others text object populated when I insert a new record.
If I change the lookup value, the text fields change correctly.
But no value is displayed in text fields if I open the edit form on an existing record: maybe I have to put some js in the JavaScript field of lookup object to work? Doesn't nuBuilder do it by default?

Thanks.
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

Re: lookup object don't display other fields

Unread post by admin »

massiws,

Fields other than the lookup code and lookup description will be populated only when the lookup value changes. Other fields that get populated at this time need to be saved to a field of the same name on that record. Just the same as any other Text Object.

I hope this answers you question

Steven
massiws
Posts: 503
Joined: Thu May 24, 2012 2:08 am
Location: Milan, Italy
Contact:

Re: lookup object don't display other fields

Unread post by massiws »

I thought the fields specified in "Update Other Fields" section in the lookup tab where populated at the same time of code and description of lookup object.
I will try to find a way to do it with javascript.

Thanks.
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

Re: lookup object don't display other fields

Unread post by admin »

massiws,

The best way to do what you want is by using a Display Object.

http://wiki.nubuilder.com/tiki-index.ph ... uilderDocs

Theree is a bit more info 4:43 minutes into this tutorial http://www.youtube.com/watch?v=op-IM5hTgU0

When you select a record from the Lookup it can populate things the way you want them, but when you return to the record it will be populated by an sql select statement.

Steven
massiws
Posts: 503
Joined: Thu May 24, 2012 2:08 am
Location: Milan, Italy
Contact:

Re: lookup object don't display other fields

Unread post by massiws »

admin,
sorry, I'm embarrassed, but I wasn't able to use a display object! :oops:
I several times read the wiki and listen the tutorial, but this don't explain so much (maybe I don't understand).

My sql is:

Code: Select all

SELECT * FROM repair AS r 
INNER JOIN (
client AS c, atype AS t, brand AS b, repair_status AS rs
) ON (
r.rep_cli_id = c.cli_id AND 
r.rep_typ_id = t.typ_id AND 
r.rep_bra_id = b.bra_id AND 
r.rep_rst_id = rs.rst_id
)
LEFT JOIN (supplier as s) ON (r.rep_sup_id = s.sup_id) 
ORDER BY r.rep_number DESC
I want to display on the form the cli_address value from client table.

In the "Field Name" field on the All tab I put "cliAdr", to populate the field with the lookup object, and this work perfectly.
In the "SQL to display" field in the Display tab I put this:

Code: Select all

SELECT cli_address FROM client WHERE cli_id = '#rep_cli_id#'
but this return nothing.

In debug I can see that the HashVariable #rep_cli_id# is present with the right value.
Perhaps can the display objects return only values ​​stored in the main table (in this case repair table)?

Sure I forget something, but I can not understand what! :oops:

Any suggestion will be apreciated!
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

Re: lookup object don't display other fields

Unread post by admin »

massiws,

I have rewritten part of the Wiki on Display Objects. Hopefully it explains things better now.

http://wiki.nubuilder.com/tiki-index.ph ... isplay+Tab

It sounds like you are trying to fill in fields on the Display Tab when you are making a Lookup Object.

The Display Tab is only used for Display Objects.

To achieve what you want you will need 1 Lookup Objects and a number of Display Objects.

Steven
massiws
Posts: 503
Joined: Thu May 24, 2012 2:08 am
Location: Milan, Italy
Contact:

Re: lookup object don't display other fields

Unread post by massiws »

I found my bug!! :oops:

As I said in a previous post, when I insert a new record I want to select a customer with a lookup object and populate other fields (address, phone, etc.). Also I want to display these fields when I show an existing record on edit form.
Your suggestion to use a lookup object for the customer select and display objects for the other fields was correct.
My error was in the HashVariable in the SQL sentence of the display object. This don't work:

Code: Select all

SELECT cli_address FROM client WHERE cli_id = '#rep_cli_id#'
I have rewritten the SQL sentence in the display object:

Code: Select all

SELECT cli_address FROM client INNER JOIN repair ON cli_id = rep_cli_id WHERE rep_id = '#id#'
I think my mistake was considering the #rep_cli_id# HashVariable: only #id# work fine; if I understand well, the #id# HashVariable is ALWAYS referred to the primary table that retrive the data to edit, in my case repair table.
The wiki is more comprehensible now!

However, all's well what ends well! :D

Thanks Steven.
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

Re: lookup object don't display other fields

Unread post by admin »

massiws,

Well done, with the help of sql a Display Object can be very powerful.

Steven
Post Reply