Usecase : How to keep track of database entries with all the previous changes from the time when the row got created
- > How many times a specific row has been modified ?
- > Who are all modified a specific row when and what modified ?
Approach
- Create below four columns in Database table, synchronize the respective entity to reflect these attributes.
- Modify the Entity Object to 'EffectiveDated' , Open the Entity, Select 'General' , Modify the 'Effective Date Type' attribute to 'EffectiveDated' using property inspector.
- Set 'Sequece' attribute value to 'true' for 'EffectiveSeq' attribute using Property Inspector
- Set 'Sequece Flag' attribute value to 'true' for EffectiveSeqFlag' attribute using Property Inspector
- Set 'Start Date' attribute value to 'true' for 'StartDate' attribute using Property Inspector
- Set 'End Date' attribute value to 'true' for 'EndDate' attribute using Property Inspector
- Set 'Effective Dated' attribute of corresponding View Object to 'true' using property inspector
- Finally, Set the 'EffeciveDateMode' at row level, You can set this property wherever needed based on the requirement, In this example, I am setting this at constructor of the Row Impl class, so whenever new row inserted/updated/deleted/created this will be invoked and set the value accordingly.
- Below shows what exactly meant for each mode level in ADF, Mode level can be set based on the requirement.
Row.EFFDT_UPDATE_MODE: When an effective dated row is updated in "update" mode, the modified row is end dated on the effective date and a new row is created with the changed values.
Row.EFFDT_UPDATE_CHANGE_INSERT_MODE: When an effective dated row is updated in "change insert" mode, the modified row is end dated on the effective date and a new row is inserted that fits between the effective date and the start date of the next row in the effective date time line.
Row.EFFDT_UPDATE_CORRECTION: When an effective dated row is updated in "correction" mode, the effective start date and effective end date is left unchanged.
Row.EFFDT_UPDATE_NEW_EARLIEST_CHANGE_MODE: Updating in "new earliest change" mode is supported only in Multiple Changes Per Day.
Row.EFFDT_UPDATE_OVERRIDE_MODE: When an effective dated row is updated in "override" mode, the modified row is end dated on the effective date and the start date of the next row in the effective date time line is set to effective date + 1 day.
Row.EFFDT_NONE_MODE: Default state of the effective date mode on the row.
ADF Framework automatically updates for all the above attributes upon Create/Update/Delete operations
- All set, Run the app module, Create new row and see how the values are populated in DB table automatically.. ADF will take care of populating these values based on 'EffectiveDateMode'
Thanks - I hope this may help.