The write() method is a standard method of a form data source. This method is called when a record is modified and when you've attempted to save it by selecting the Save button or navigating out of the record.
Example
You have a custom form with a table named TrainingMaster. The table has a real field called Price that indicates the total price of the trainer. It also contains an integer field called NoofDays that indicates the duration of the training. Additionally, the table has a field named TrainerID, which creates a foreign key with the TrainerTable. The TrainerTable has a real field called Rate, which captures the daily rate of the trainers.
After you've saved the record in the TrainingMaster table, the Price field of the TrainerMaster table should be updated with the multiplication of NoofDays and Rate of the TrainerTable.
The coding pattern is as follows:
[DataSource] class TrainingMaster { public void write() { TrainingMaster.Price = TrainerTable::find(TrainingMaster.TrainerID).Rate * TrainingMaster.NoofDays; super(); } }
First read the answer fully, then try to explain it in your own words. After that, open a few related questions and compare the concepts. This method helps you remember the topic for a longer time and improves exam preparation.