Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

How to realize lookup of two or more data

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
hujunhong
Posts: 7
Joined: Tue Apr 05, 2022 10:18 am

How to realize lookup of two or more data

Unread post by hujunhong »

Cp_Invoice.png
Cp_customer.png
Cp_contact.png

1,What code can I use when I choose cp_Invoice_contact_id
cp_Invoice_customer->Cp_customer_name
cp_Invoice_address->Cp_customer_address
cp_Invoice_phone->Cp_contact_phone

2,What code can I use when I choose cp_Invoice_contact_id
cp_Invoice_date -> today's date
You do not have the required permissions to view the files attached to this post.
Last edited by hujunhong on Tue Apr 05, 2022 6:11 pm, edited 7 times in total.
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: How to realize lookup of two or more data

Unread post by kev1n »

Hi,

You can use PHP in the After Browse event for that Lookup to populate these additional fields.

The function you need is nuSetFormValue
hujunhong
Posts: 7
Joined: Tue Apr 05, 2022 10:18 am

Re: How to realize lookup of two or more data

Unread post by hujunhong »

kev1n wrote: Tue Apr 05, 2022 1:40 pm Hi,

You can use PHP in the After Browse event for that Lookup to populate these additional fields.

The function you need is nuSetFormValue
Thank you Kevin
2,cp_Invoice_phone_id->Cp_contact_phone
nuSetFormValue('cp_Invoice_phone',nulookupRecord()->Cp_contact_phone);
it is ok
but 3 and 4 cp_Invoice_customer and cp_Invoice_address is not
I tried nuSetFormValue only in the same table, but my information is two tables, how to use code?
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: How to realize lookup of two or more data

Unread post by kev1n »

hujunhong wrote: Tue Apr 05, 2022 1:32 pm 2,What code can I use when I choose cp_Invoice_contact_id
cp_Invoice_date -> today's date
Use this JavaScript in the lookup's LUJS field:
setdate.png
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: How to realize lookup of two or more data

Unread post by kev1n »

Can you show the SQL of the lookup form?
hujunhong
Posts: 7
Joined: Tue Apr 05, 2022 10:18 am

Re: How to realize lookup of two or more data

Unread post by hujunhong »

kev1n wrote: Tue Apr 05, 2022 2:26 pm Can you show the SQL of the lookup form?
sql.png

Code: Select all

SELECT
 Cp_Invoice.*,
    Cp_contact.*,
    Cp_customer.*

FROM
    Cp_Invoice
        JOIN Cp_contact ON Cp_Invoice.cp_Invoice_contact_id = Cp_contact.Cp_contact_id
        JOIN Cp_customer ON Cp_contact.Cp_contact_customer_id = Cp_customer.Cp_customer_id
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: How to realize lookup of two or more data

Unread post by kev1n »

nuLookupRecord() will only return the the fields of the table used by the Lookup. You can add an additional query to retrieve the other values.

Example:

viewtopic.php?p=15921#p15921
hujunhong
Posts: 7
Joined: Tue Apr 05, 2022 10:18 am

Re: How to realize lookup of two or more data

Unread post by hujunhong »

kev1n wrote: Tue Apr 05, 2022 6:20 pm nuLookupRecord() will only return the the fields of the table used by the Lookup. You can add an additional query to retrieve the other values.

Example:

viewtopic.php?p=15921#p15921
thank you kevin.problem solved
Post Reply