Clear and Clear_All
You will use the Clear or Clear_All messages to clear Data Dictionary Objects (DDOs). The Clear message will clear the DDO and all connected parent DDOs. If parent DDOs have a relates-to constraint between them, the clear activity will be blocked by the constraint (i.e., the parent and any of its parents will not be cleared).
Clear_All unconditionally clears all DDOs in a structure.
After a Clear or Clear_All, any attached Data Entry Objects (DEOs) will be notified of the change.
Clear Operation Steps
A Clear performs the following steps:
- Clear the main DDO and all parent DDOs up the Parent DDO tree (Clear_Main_File).
- If a relates-to constraint is in effect, stop the upward clear propagation.
- If a related-to child exists, clear the child (Clear_Main_File) and all of its parents.
- Send OnNewCurrentRecord to all cleared DDOs.
- Send Refresh to all DEOs attached to DDOs that were cleared.
Clear_All Operation Steps
A Clear_All performs the following steps:
- Clear every DDO in the structure (Clear_Main_File).
- Send OnNewCurrentRecord to all cleared DDOs.
- Send Refresh to all DEOs attached to DDOs that were cleared.
Example: Clear Operation in a Web Object or Business Process
A clear operation may be programmed within a Web Object or Business Process object as follows:
Function ClearUser Returns Integer
Handle hoDD
Move oCustomer_DD to hoDD
Send Clear of hoDD
End_Function // ClearUser
The clear operation is often combined with other operations.
Function FindUser String sCustNo Returns RowId
RowId riRecId
Handle hoDD
Move oCustomer_DD to hoDD
Send Clear of hoDD
Move sCustNo to Customer.Customer_Number
Send Find of hoDD EQ 1
Get CurrentRowId of hoDD to riRecId
Function_Return riRecId
End_Function // FindUser
Clears and DEOs
The above sample shows how to use clears in batch processes. The Clear and Clear_All operations are built into Data Entry Objects (DEOs), allowing the user to direct the operation. A Clear (or Clear_All) is started when the user presses a key (F5), clicks on a button, or selects a menu option. This sends the message Request_Clear (or Request_Clear_All) to the DEO. The DEO will then:
- Check if any changes exist, and if they do, verify a data-loss condition.
- Send Clear (or Clear_All) to the DDO.
Below is an example of a simplified DEO Request_Clear procedure. These are the types of methods and functionality built directly into DEOs.
// The DEO Clear Process
Procedure Request_Clear
Handle hoDDO
Boolean bChanged bError
Get Server to hoDDO
Get Should_Save of hoDDO to bChanged // Are there changes?
If bChanged Begin
Get Verify_Data_Loss to bError // Do we really want to clear?
If bError Procedure_Return // User decided not to clear
End
Send Clear of hoDDO // This will clear and notify all DEOs
End_Procedure