✏️ Explanatory Question

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

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

Answer with Explanation

The delete() method is a standard method of a form data source. This method is called when a record is deleted.

Example

You have a custom form with a table named TrainingMaster. The table has a field named TrainerID, which has a foreign key relation with the TrainerTableTrainerTable has a field named TrainingCount. The requirement is to reduce the TrainingCount number by one if a record is deleted from the TrainingMaster table.

The coding pattern can be as follows:


public void delete()
        {
            TrainerTable    trainerTable;
            ttsbegin;
            trainerTable = TrainerTable::find(TrainingMaster.TrainerID, true);
            trainerTable.TrainingCount = trainerTable.TrainingCount - 1;
            trainerTable.update();
            ttscommit;
            super();
            
        }