Page 1 of 1

Pass Parent Form Record ID to Iframe Form in nuBuilder

Posted: Sat Apr 12, 2025 10:55 pm
by yvesf
hello,


I have a Patients form, which includes an iframe that loads the Consultation form in edit mode.

I want to automatically set the cs_patient_id field in the Consultation form to the current patients_id from the parent form.

To find how the patient ID is passed, I used nuDebug(nuHash()) in the Before Edit event of the Consultation form and saw that the correct value is stored in the record_id cookie.

So, I wrote a procedure that retrieves record_id and uses nuJavaScriptCallback() to set the cs_patient_id. This script is triggered in the onnuload event of the cs_patient_id field.

But instead of getting the patient ID, the value becomes -1. When I try using RECORD_ID, I get the procedure name instead.

I'm stuck and can't figure out how to properly assign the patient ID to cs_patient_id.

Attached a simple example of what I am trying to achieve : pass the record id of the parent form to level below.
2025-04-12_204157_67fade257d779_nuBuilder_backup.zip
Any help would be greatly appreciated!

Yves

An alternative would be to create an hidden display field retrieving the record_id of the patient for that but as we have the hash cookie, it would be nicer to retrieve it via the right formula. In any case, I would like to know the best practice for this kind of pb

Re: Pass Parent Form Record ID to Iframe Form in nuBuilder

Posted: Sun Apr 13, 2025 7:30 am
by kev1n
Hi Yves,

Since the procedure is executed from within the iframe—which contains a new, unsaved record—the record ID returned will be -1.

An easier approach would be:

Code: Select all

nuGetLookupId(parent.nuRecordId(),'vs_patient_id');
and to set the Slot datetime, use

Code: Select all

nuSetValue(this.id, nuCurrentDateTime());