Using a Child Record's generated key to populate Parent Record
Something I have been un-aware of, probably due to never actually trying or needing..
Lets say you have a relationship as follows ParentTable::keyfield = ChildTable::keyfield
and a Layout based on ParentTable, showing related fields from ChildTable
Obviously, if ParentTable::keyfield contains 1
then any child records created over this relationship will have the ChildTable::keyfield set to 1.
What I didnt realise was,
If ParentTable::keyfield is empty and ChildTable::keyfield is set to auto generate
Entering data into the related fields such as ChildTable::fieldA would populate the ParentTable::keyfield with the value from ChildTable::keyfield
to make the relationship valid.
Obviously, in this scenario I would only want a single related record.
Normally, what I would do here is go to the related record table
Create a new record
Grab the ChildTable::keyfield into a variable
Return to the original layout
Set the ParentTable::keyfield to the variable.
Q. Has it always worked this way ? Have I just been overlooking this for years !
I feel a bit stupid asking this question to be honest, it makes sense why it works, I just wasnt expecting it to.
I was expecting something along the lines of "This field cannot be modified until "ParentTable::keyfield" is given a value.