Welcome to the nuBuilder Forums!

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

Retrieve data from another table on load in an edit form Topic is solved

Questions related to using nuBuilder Forte.
Post Reply
yvesf
Posts: 315
Joined: Sun Mar 14, 2021 8:48 am
Location: Geneva
Has thanked: 87 times
Been thanked: 11 times

Retrieve data from another table on load in an edit form

Unread post by yvesf »

I have 2 tables:
- Patient table
Patient_id
Patient_FirstName <-- Text
Patient_LastName <-- Text
Patient_DOB <-- Date
- Task table
Task_id
Task_Name <-- Varchar(100)
Task_select_patient <-- Select field
Task_pat_DOB <-- Display field

I don't want to save the DOB in the Task table to avoid data duplication. It is the reason why it is a display field.

In the Task Edit form, I would like to retrieve more than the firstname and the lastname but also the DOB (Date of Birth). I perform that by inserting PHP code after Browse :
$lu = nuLookupRecord();
nuSetFormValue('tsk_pat_DOB', $lu->Patient_DOB);
I retrieve the patient DOB perfectly.
But when I reopen the task record, I don't retrieve the DOB. Behind the display field I have the request "Select Patient_DOB from Patient". It doesn't retrieve the DOB of the current patient but the first DOB in the database. I have to use the Hash Cookie but I don't know how to perform that.
Could you please help ?
Many thanks,

Yves
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Retrieve data from another table on load in an edit form

Unread post by kev1n »

You need to select the DOB of the selected patient like

Code: Select all

SELECT Patient_DOB FROM Patient
WHERE Patient_id = '#id_of_your_lookup_here#'
yvesf
Posts: 315
Joined: Sun Mar 14, 2021 8:48 am
Location: Geneva
Has thanked: 87 times
Been thanked: 11 times

Re: Retrieve data from another table on load in an edit form

Unread post by yvesf »

Hello Kev1n,

I am certainly doing something wrong.
Here is the display field
all.png
request.png
and the related lookup
idlookup.png
Lookup tab.png
When I open the record, it seems that the sql request behind the display field isn't executed.The display field stays empty.
displayFieldEmpty.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: Retrieve data from another table on load in an edit form

Unread post by kev1n »

Try with lowercase: #id_patient#
yvesf
Posts: 315
Joined: Sun Mar 14, 2021 8:48 am
Location: Geneva
Has thanked: 87 times
Been thanked: 11 times

Re: Retrieve data from another table on load in an edit form

Unread post by yvesf »

Yes of course, brilliant Kev1n !!!
Post Reply