✏️ Explanatory Question

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

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

Answer with Explanation

The active() method is a standard method of a form data source that's called when a user navigates to a new record.

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, which has two values of Online and Classroom. While you're navigating through the records, the Venue field will be uneditable if TrainingType is Online. Otherwise, the Venue field will be editable.

The code pattern should be as follows:


[DataSource]
class TrainingMaster
    {
        public int active()
        {
            int ret;
        
            ret = super();
            TrainingMaster_ds.object(fieldNum(TrainingMaster, 
            Venue)).allowEdit(TrainingMaster.TrainingType == TrainingType::Classroom);
        
            return ret;
        }
    }