Detail-with-two-masters
A detail-with-two-masters relation involves a single detail block that has two master blocks. Form Builder displays the appropriate detail records for whichever master block is the current block in the form. For example, in the sample application referred to earlier, the ord block could be a detail block having two master blocks, CUSTOMER and EMP. End users could then see all of the orders for a particular customer, or for a particular sales representative (employee).
Usually, when you create a detail-with-two-masters relation, you will be joining on different foreign-key items in the detail block. In such cases, the Copy Value from Item property is set for each foreign-key item in the detail block to point to the primary-key item in the appropriate master block. To create this type of relation, you need only define the two relations; Form Builder will automatically support coordination.
In other cases, however, you might want to create a master-with-two-details with each relation joining on the same foreign-key item in the detail block. However, because the Copy Value from Item property can only point to one master block item, you will need to write additional code to coordinate querying and updating for the second relation if you are joining on the same item in the detail block.
Depending on the desired functionality, this might include writing a Pre-Query trigger for the detail block to ensure that the correct primary-key item value is copied to the foreign-key item in the detail block. For example,
COPY(NAME_IN(:system.master_block||'.primary_key_item'),
'detail_block.item');
You might also want to create a When-New-Block-Instance trigger that checks the coordination status of the detail block whenever the end user navigates to a different master block, and, if necessary, populates the detail block.
Partager