Retrieve data from another table on load in an edit form
Posted: Fri Apr 22, 2022 7:36 pm
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
- 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