Constraints in DDOs determine how records are filtered and how finds are propagated. Constraints and Find Filters are discussed in Constraints and Filters. A short review of is presented here.
Relates-to-constraints are used to constrain the display of child records to a record in a related to parent.
Constrain_File: Setting the Constrain_File property in the child DDO creates a relates-to-constraint.
When a relates-to-constraint is in place the propagation rules of finds and clears are changed (saves and deletes are unchanged). Propagation is changed as follows:
The finding of child records is limited to records that are related to the parent
Clearing a child DDO will not clear the constraining parent DDO.
Finding a constraining parent record will send a notification to the constrained child DDO. The child must either find a valid constrained record or clear itself.
Clearing a constraining parent record will send a notification to the constrained child DDO forcing it to clear.
Two properties, Auto_Fill_State and pbAutoFillFromFirst, determine how a constrained child should react to a changed parent.
Auto_Fill_State: If Auto_Fill_State is false, changing a constraining parent record will force the child DDO to clear itself. If Auto_Fill_State is True, changing a constraining parent record will force the child to find its first or last record.
Auto_Fill_State only takes effect when a relates-to constraint is in effect.
pbAutoFillFromFirst: This property determines if an auto-fill should find the first or last constrained record. When true, the default, the first constrained child record is found; when false the last constrained record is found. This only takes effect when Auto_Fill_State is true and a relates-to constraint is in effect.
Filter constraints represent all non-relational constraints that are used to filter records by any set of restrictions. Filter constraints are defined within a DDO’s OnConstrain method and are specified within this method by using the Constrain command.
There are two basic types of filters – The File.Field Filter and the Constrain-As Filter.
A Constraint set is usually built once and then used many times. Normally this building process occurs automatically when a view is activated or a report is run. If you change your constraints you can rebuild constraints manually using by sending the Rebuild_Constraints message.
Inheritance of constraints specifies if child DDOs should use their parent constraints and filters. When a constraint set is built for a DDO it normally inherits the constraints from its parent DDO and all of their ancestor DDOs. This can be disabled by setting the pbInheritConstraints property to false.
When finding using constraints and filters you want to make sure that the finding will be properly optimized. This normally, requires that you build a constraint that is capable of using an index that can be jumped in and out of.
If your constrained find only has one index that can be used in an optimized fashion you should make sure you use that index in your finds. You can force a DDO to use a particular index by setting the Ordering property.
Find and Clear Operations in DDOs