Consultor Eletrônico



Kbase P127154: How to make fields read-only in a ProDataSet temp-table when updating
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   12/2/2008
Status: Verified

GOAL:

How to make certain fields read-only in a ProDataSet temp-table when updating

GOAL:

How to specify an except list in a ProDataSet temp-table when saving changes

GOAL:

SAVE-ROW-CHANGES except list is specific to new records. How do I update with an except list?

FACT(s) (Environment):

All Supported Operating Systems
OpenEdge 10.x

FIX:

When saving changes from a ProDataSet temp-table back to the database, if you want to prevent changes to some fields in the data-source, you might think you would use the except list in the SAVE-ROW-CHANGES method. This solution will work for newly created rows but is ignored when saving changes to existing rows.
Sometimes an application developer will have specific fields in tables that can be read but should not be changed. If the application is properly split, using ProDataSets on the back-end and virtually any front-end, the ABL developer may not be able to control what fields are updated in the front-end user interface, but this can be controlled in the ProDataSet save code.
This solution discusses ways to enforce data security from the back-end and doesn't address best practices which would likely include publishing an API to front-end developers to inform them which fields are read only. The ABL provides to mechanism, per se, to enforce maintaining READ-ONLY fields in a temp-table.
To specify read only fields in this fashion use one of the following methods:
1) The except fields option in the ATTACH-DATA-SOURCE method can be used just prior to saving changes to the database table(s). If the DATA-SOURCE is already attached when saving it should first be detached then re-attached specifying the fields to exclude. This method requires some type of further synchronization to resolve conflicts in changed records from the database.
2) Use a validation hook which resets the read-only fields' values from the AFTER-BUFFER value.
3) Add the fields as calculated fields to the proDataSet temp-table and use an AFTER-FILL event to populate them. This solution would also require that the field be added to the except fields parameter anywhere the ATTACH-DATA-SOURCE method is used.