Implementing custom validation fix using Database Consistency Checks feature
Views (244)
Hi,
In this post, we will see how can we fix custom validation checks when we run database consistency checks feature.
- Created new tables by name SampleTable and SampleTrans and loaded some data into it.
- Developed a class by name CGConsistencyCheck and included a validation fix where if due date of record in table SampleTrans is latest when compared to due date on its corresponding record of table SampleTable then info message will be shown with the corrected record details.
- Method run of class CGConsistencyCheck
public void run(){SampleTable sampleTable;SampleTrans sampleTrans;while select optimisticlock DueDate, Id from sampleTablejoin DueDate, RecId, RecVersion, RefId, TransID from sampleTranswhere sampleTrans.RefId == sampleTable.Id{if (sampleTrans.DueDate > sampleTable.DueDate){if (this.checkFix() == CheckFix::Check){checkFailed(strfmt("Due date on Transaction %1 exceeds due date when compared -
to due date on its respective header %2", sampleTrans.TransID, sampleTable.Id));this.updateNotCorrected();}if (this.checkFix() == CheckFix::Fix){ttsbegin; -
sampleTrans.selectForUpdate(true);sampleTrans.DueDate = sampleTable.DueDate;sampleTrans.update();ttscommit;info(strfmt("Due date on Transaction %1 matched with due date when compared -
to due date on its respective header %2", sampleTrans.TransID, sampleTable.Id));this.updateCorrected();}}}}. - On executing Consistency check by selecting the node Custom and Fix error as option for Check/Fix dialog, we get the messages for the SampleTrans records where fix happened.
Output: Info message and Message details
Regards,
Chaitanya Golla

Like
Report
*This post is locked for comments