hi. This code this works for me
a) Case of details subform, where form table are the same of popup table
In Open Button Onclick()
if (nuIsNewRecord() == '-1' || nuSubformRowId(this) == '-1') {
nuMessage(['Alert','You must save berfore continue']);
}
else {
if (nuIsSaved()) {
nuPopup('151418fe772495',nuSubformRowId(this)); //Open Subform in an specific same record_id of subform_id
}
else {
nuMessage(['Alert','You must save berfore continue']);
}
}
Captura de pantalla 2023-07-15 212112111.png
b) Case passing variable to a popup from subform In response of
johan wrote: ↑Tue Jul 04, 2023 8:58 am
Kev1n
It open a new form with extra info to add to the subform. That part works.
But I need the id of the main form to be saved as the foreign key of that subform.
if you need to pass a variable what i do is
1. on OnClick evengt on Button "Open"
nuSetProperty('subform_id',nuSubformRowId(this));
nuSetProperty('main_id',nuGetProperty('record_id'));
if (nuIsNewRecord() == '-1' || nuSubformRowId(this) == '-1') {
nuMessage(['Alert','You must save berfore continue']);
}
else {
if (nuIsSaved()) {
nuPopup('151418fe772495',nuSubformRowId(this));
}
else {
nuMessage(['Alert','You must save berfore continue']);
}
}
2. In your Popup Form create a display object named "main_id" to obtain the globalvariable
Captura de pantalla 2023-07-15 210023.png
and be sure to create a field object to be filled with the foreignkey (main_id)
3. In Custom Code of Popup Form:
if (nuFormType() == 'edit') {
if (nuIsNewRecord()) {
$('#foreign_key').val($('#main_id').val()).change(); //here obtain the main_id value and write on the foreing key value
}
}
4. Hide when "main_id" display and your you foreign_key objects and finish.
Now when open the popup automatically the foreign_key will be populated with your "main_id" and you can save