The solution depends on how/where the form is opened (new tab, same breadcrumb, new breadcrumb) etc. See
Related question)
A button for creating a new record in B with foreign key being automatically filled as A.id (and being invisible/uneditable).
Using sessionStorage allows you to transfer a value from one form to another, regardless of where it is opened (New Breadcrumb, new tab, came Breadcrumb etc.)
Set a Hash Cookie in the button's onclick event:
- Code: Select all
sessionStorage.setItem('PK_A',nuCurrentProperties().record_id);
In the 2nd form (in the form's Custom Code):
- Code: Select all
var fk = sessionStorage.getItem('PK_A'); // Retrieve the PK of Table A
sessionStorage.removeItem('PK_A'); // Remove the item from session storage
$('#Object_FK_ID)').val(fk).change(); // Assign the fk value to the object with ID "Object_FK_ID" on the 2nd form
A button for browsing records in B having foreign key being A.id
Set a global Hash Cookie in the button's onclick event. It the form is going to be opened in the same Breadcrumb, the third parameter can be omitted.
- Code: Select all
nuSetProperty('PK_A', nuCurrentProperties().record_id, true)
and in the 2nd form's Browse use that to filter like:
- Code: Select all
WHERE foreign_key = '#PK_A#'