Pass record id from 1 form to another linked form
Posted: Thu Jul 24, 2025 9:42 pm
Hello,
I’m working with two tables: patients and consultations. In the consultations table, I have a lookup field cs_patient_id that references patient_id from the patients table.
I’ve created two browse and edit forms—one for each table. From the patient form, I want to display the list of consultations related to the current patient. To do this, I’ve added a Run button that opens the consultations list, filtered by record_id. This retrieves all consultations linked to the current patient.
My questions:
Is this an efficient way to do it in terms of performance?
Would it be better to use a browse form with a WHERE clause directly filtering on record_id?
Additionally, I’ve created a second button on this patient's form to create a new consultation. It opens the consultation form, and I want to automatically populate the cs_patient_id lookup field with the current patient’s ID.
To achieve this:
I created a display field in the patient's form that retrieves patient_id with WHERE patient_id = '#RECORD_ID#'.
Then I use nuSetProperty to store this value in a global field (current_patient_id), so I can use it to populate cs_patient_id when the consultation form opens.
Is this the recommended approach, or is there a better way to pass the current RECORD_ID when opening a child form?
I’m asking because it seems RECORD_ID is not always reliably set, especially when reopening an existing patient record.
The related database : Thanks a lot for your guidance,
Yves
I’m working with two tables: patients and consultations. In the consultations table, I have a lookup field cs_patient_id that references patient_id from the patients table.
I’ve created two browse and edit forms—one for each table. From the patient form, I want to display the list of consultations related to the current patient. To do this, I’ve added a Run button that opens the consultations list, filtered by record_id. This retrieves all consultations linked to the current patient.
My questions:
Is this an efficient way to do it in terms of performance?
Would it be better to use a browse form with a WHERE clause directly filtering on record_id?
Additionally, I’ve created a second button on this patient's form to create a new consultation. It opens the consultation form, and I want to automatically populate the cs_patient_id lookup field with the current patient’s ID.
To achieve this:
I created a display field in the patient's form that retrieves patient_id with WHERE patient_id = '#RECORD_ID#'.
Then I use nuSetProperty to store this value in a global field (current_patient_id), so I can use it to populate cs_patient_id when the consultation form opens.
Is this the recommended approach, or is there a better way to pass the current RECORD_ID when opening a child form?
I’m asking because it seems RECORD_ID is not always reliably set, especially when reopening an existing patient record.
The related database : Thanks a lot for your guidance,
Yves