Date effectiveness allows developers to easily create date range fields. Date ranges are used to define record validity between the specified dates, for example, defining employee contract dates and defining vendor license validity.
This feature significantly reduces the amount of time that developers spend on developing business logic/code and also provides a consistent approach to implement data range fields.
This recipe will demonstrate the basics of date effectiveness. We will create a new table to implement date range validation.
Carry out the following steps in order to complete this recipe:
Run Visual Studio as admin:
- Load your earlier project.
- Add a new
Table
PktEmployeeContract.
Set the property as follows:
Property | Value |
ValidTimeStateFieldType | Date |
Note the two new fields that are automatically added to the table, as shown in the following screenshot (ValidTo
and ValidFrom
):
- Now create a new index as follows and add fields as follows:
- Set the following mentioned property for the index here:
Property | Value |
AlternateKey | Yes |
ValidTimeStateKey | Yes |
ValidTimeStateMode | NoGap |
- Now open the table and enter some records in this table itself instead of creating a new form for the table. Right-click on
Table
and selectBrowse table
:
We start the recipe by setting the ValidTimeStateFieldType
property to Date
in the SysEmailTable
table. This automatically creates two new fields--ValidFrom
and ValidTo
that are used to define a date range.
Next, we add the created fields to the primary index where the EmplNum
field is used and adjust the index's properties.
We set the AlternateKey
property to Yes
in order to ensure that this index is a part of an alternate key.
We set the ValidTimeStateKey
property to Yes
in order to specify that the index is used to determine valid date ranges.
We also set the ValidTimeStateMode
property to NoGap
in order to ensure that email templates with the same identification number can be created within continuous periods. This property can also be set to Gap
, allowing noncontiguous date ranges.