✏️ Explanatory Question

modified() - Form data source field methods in D365 F&O - X++ Code

👁 1,671 Views
📘 Detailed Answer
🟢 Easy
💡

Answer with Explanation

The modified() method is a standard method on the field of the form data source. This method is called when the value of a specific field is modified.

Example

You have a custom form with a table named TrainingMaster. The table has a field named Venue and an enum type field named TrainingType that has two values: Online and Classroom. If Online is selected for the TrainingType, the Venue field should become blank.

The coding pattern can be as follows:


[DataSource]
class TrainingMaster
    {
        [DataField]
        class TrainingType 
        {
            public void modified()
            {
                super();
                if(TrainingMaster.TrainingType == TrainingType::Online)
                    TrainingMaster.Venue = "";
            }
        }
    }