Omit foreign key fields in nested child records
- Last Updated: June 13, 2019
- 1 minute read
- OpenEdge
- Version 13.0
- Documentation
When working with a nested data relation in a ProDataSet,
the fields that define the relationship appear in both the parent
record and the child records. Because the child records are contained
within the parent record, the foreign key fields in the child records
are redundant. The WRITE-JSON( ) method
omits these foreign key fields if you:
- Specify the
FOREIGN-KEY-HIDDENoption on aDEFINE DATA-RELATIONstatement - Specify the
foreign-key-hiddenargument on theADD-RELATION( )method of a Data-relation object - Set the
FOREIGN-KEY-HIDDENattribute of a Data-relation object toTRUE
In all three cases, you must also specify the NESTED option
for the data-relation.
Before using this option, consider carefully whether the consumers
of the JSON data will handle the missing key fields appropriately.
In ABL, the READ-JSON( ) method automatically populates
foreign keys in nested child records with the value in the outer parent
record when the foreign key is omitted from the JSON data. Unless
you are sure that a non-ABL consumer of the JSON data will do the
same, do not use this option in your nested data-relations.
For example, while a Web browser can read the JSON data and populate a JavaScript object, it will create rows in the nested table without the foreign key field.