✏️ Explanatory Question

validateDelete() - form data source methods - in D365 F&O

👁 184 Views
📘 Detailed Answer
🟢 Easy
184
Total Views
8
Related Qs
0%
Progress
💡

Answer with Explanation

The validateDelete() method is a standard method of a form data source, which is called when a user attempts to delete a record, to confirm the deletion.

Example

You have a custom form with a table named TrainingMaster. The table has a date field named TrainingDate. No backdated training data should be deleted.

The following code pattern can be a way to achieve this result:


[DataSource]
class TrainingMaster
    {
        public boolean validateDelete()
        {
            boolean ret;
        
            ret = super() && (TrainingMaster.TrainingDate >= today());
        
            return ret;
        }
    }

Note

You should throw an error with a message rather than let the validateDelete() method silently fail.