Custom code form - subform
Posted: Wed Nov 24, 2021 2:19 pm
Hi Kevin, I need your help.
I have an FF6 form in which information can be added.
I also have an FF0 form that contains as a subform, the FF6 form.
In FF0 I just want to add or delete records in the FF6 subform (the record should not be deleted from the database only the updated FK field in the FF6 subform).
From the properties of the subform I deactivated "delete checkbox".
I added an "Add / Del" button in the FF6 subform, which I want to execute the following:
- if pk <> -1 will run the procedure "deleteCommand" the field FK will be updated with "" (nothing) so that record will no longer appear in the subform FF6, when FF0 form is in edit mode
(works here);
or
- if pk = -1 to open a popup with FF6 and to be able to select a record so as to update FK whit form_id of the form FF0 .... here I am blocked
I added this in custom code of FF0 form, (event from "Add / Dell" button)
Procedure for deleting the foreign key (working)
Procedure that adds the foreign key (not working)
In the custom code of subform FF6 I add this:
I want to populate these fields one by one with record_id from the FF0 edit form Thanks, Gerese
I have an FF6 form in which information can be added.
I also have an FF0 form that contains as a subform, the FF6 form.
In FF0 I just want to add or delete records in the FF6 subform (the record should not be deleted from the database only the updated FK field in the FF6 subform).
From the properties of the subform I deactivated "delete checkbox".
I added an "Add / Del" button in the FF6 subform, which I want to execute the following:
- if pk <> -1 will run the procedure "deleteCommand" the field FK will be updated with "" (nothing) so that record will no longer appear in the subform FF6, when FF0 form is in edit mode
(works here);
or
- if pk = -1 to open a popup with FF6 and to be able to select a record so as to update FK whit form_id of the form FF0 .... here I am blocked
I added this in custom code of FF0 form, (event from "Add / Dell" button)
Code: Select all
function addDelCmd(event){
var id = event.target.parentNode.id;
var pk = $('#' + String(id)).attr('data-nu-primary-key');
if (pk == '-1') {
var r1 = nuCurrentProperties().record_id;
nuSetProperty('ECHI_COMANDA_ID', r1, 0);
nuPopup('617efff03300f00', '', ''); //subform FF6
// nuClosePopup();
} else {
nuSetProperty('deleteRow_record_id', pk);
nuRunPHPHidden("deleteComanda", 1);
}
}
function afterDeleteRow() {
nuSearchAction();
}
Code: Select all
$pk = "#deleteRow_record_id#";
$qry = "UPDATE echiplucrare SET echi_comanda_id = '' WHERE echiplucrare.echiplucrare_id = '$pk';";
nuRunQuery($qry);
// The function afterDeleteRow() must be declared in the form's Custom Code
$j = "afterDeleteRow();";
nuJavascriptCallback($j);
Procedure that adds the foreign key (not working)
Code: Select all
$pk1 = "#ECHIPLUCRARE_ID#";
$pk2 = "#ECHI_COMANDA_ID#";
//nuDebug($pk1, $pk2);
nuDebug(nuHash());
$qry = "UPDATE echiplucrare SET echi_comanda_id = '$pk2' WHERE echiplucrare.echiplucrare_id = '$pk1';";
nuRunQuery($qry);
// The function afterDeleteRow() must be declared in the form's Custom Code
$j = "afterDeleteRow();";
//nuJavascriptCallback($j);
In the custom code of subform FF6 I add this:
Code: Select all
function nuSelectBrowse(e){
var r = $('#' + e.target.id).attr('data-nu-primary-key');
nuSetProperty('ECHIPLUCRARE_ID', r);
nuRunPHPHidden("AddCmd", 0);
nuRunPHPHidden("AddCmd", 0);
nuClosePopup();
}
I want to populate these fields one by one with record_id from the FF0 edit form Thanks, Gerese