✏️ Explanatory Question

DataMemberAttribute

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

Answer with Explanation

DataMemberAttribute is another key concept in SysOperation Framework (Data Contracts) in D365 Finance & Operations (D365FO). Let’s go step by step so it’s crystal clear.


1️⃣ What it is

  • DataMemberAttribute is an X++ attribute applied to a property method in a Data Contract.

  • It marks that property as a serializable parameter for the SysOperation framework.

  • Essentially, it tells D365FO: “This field is part of the contract and should be included when passing data to the service.”


2️⃣ Why it exists

  • SysOperation services (batch jobs, AIF services) use Data Contracts to pass parameters.

  • Without [DataMemberAttribute], the framework will ignore the field, and its value will not be passed to the service.

  • It also enables the framework to generate the dialog automatically for user input.


3️⃣ How it works


[DataContractAttribute]
public class ANSARI_BatchIndividualTaskContract
{
    RecId recId;
    
    [DataMemberAttribute("RecId")]  // This field is exposed to SysOperation
    public RecId parmRecId(RecId _recId = recId)
    {
        recId = _recId;
        return recId;
    }

    int64 workItemIndex;

    [DataMemberAttribute("WorkItemIndex")]
    public int64 parmWorkItemIndex(int64 _workItemIndex = workItemIndex)
    {
        workItemIndex = _workItemIndex;
        return workItemIndex;
    }
}

  • Here, both RecId and WorkItemIndex are part of the contract.

  • When the controller executes the service, these values are serialized and passed to ANSARI_IndividualTaskService::process().


4️⃣ Key Points

Feature Explanation
Marks a field as part of the SysOperation contract Only fields with [DataMemberAttribute] are passed to the service
Works with auto-generated dialog The field appears in the SysOperation form unless hidden via SysOperationControlVisibilityAttribute
Required for batch serialization Without it, the field value will be null in the service