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. This building process is automatic and normally you do not need to concern yourself with this.
You may have constraints that need to change based on user input or other conditions. For example, you may want users to fill in the country of the customers to deal with and then constrain the DDO to that country. To make sure this change is reflected in your DDOs you must rebuild your constraints. You do this by sending the message Rebuild_Constraints to all of the DDOs that require it.
The Rebuild_Constraints method does the following:
It clears the constraint-set for the DDO receiving the message
It sends OnConstrain to the receiving DDO and adds all Constrain commands to the constraint set.
If the DDO’s Constrain_File property is set, it adds a Relates-To constraint to the constraint set.
If the DDO’s pbInheritConstraints is True, it repeats steps 2 through 4 for all Parent DDOs.
Often after changing a constraint, you may find that your current record is no longer part of the valid constraint set. Because of this, you will often need to find a new first record after rebuilding a constraint.
In the following example, a DEO sends a message to its DDO passing two parameters, the new constraint value and the index to use for finding a new first record:
Object Customer_DD is a Customer_DataDictionary
Property String psStatusConstraint
Procedure ConstraintByStatus string sStat integer iIndex
Set psStatusConstraint to sStat
Send Rebuild_Constraints
Send Find FIRST_RECORD iIndex
End_Procedure
Procedure OnConstrain
String sStat
Get psStatusConstraint to sStat
If (sStat <> "") Begin
Constrain Customer.status eq sStat
end
End_Procedure
End_Object