Header Ads Widget

🧾 Blog: How to Make Financial Dimension Value Read-Only Using X++ in D365FO

In Dynamics 365 Finance and Operations, developers can use DimensionAttributeSetStorage to customize the behavior of financial dimensions in form controls. This tutorial shows how to make a particular financial dimension value read-only (e.g., Business Unit) using X++.


🛠️ Scenario

You want to restrict users from editing a specific dimension like Business Unit while allowing edits on the rest. This can be controlled at runtime using parmEditableDimensionSet.


✅ Final Output

A financial dimension control where "Business Unit" is visible but locked for editing, while other dimensions remain editable.


🧩 Step-by-Step X++ Code (Rewritten with New Buffers)

x++
public void init() { DimensionAttribute dimAttributeBuffer; DimensionAttributeSetStorage editableDimStorage; DimensionEnumeration allowedDimensionSet; next init(); // Call base init editableDimStorage = new DimensionAttributeSetStorage(); // Loop through all financial dimensions except Business Unit while select RecId, HashKey from dimAttributeBuffer where dimAttributeBuffer.Type != DimensionAttributeType::MainAccount && dimAttributeBuffer.Type != DimensionAttributeType::DynamicAccount && dimAttributeBuffer.Name != "Business Unit" { editableDimStorage.addItem( dimAttributeBuffer.RecId, dimAttributeBuffer.HashKey, NoYes::Yes // Allow Edit ); } allowedDimensionSet = editableDimStorage.save(); // Apply the filtered set to dimension control if (allowedDimensionSet) { DimensionEntryControlTable.parmEditableDimensionSet(allowedDimensionSet); DimensionEntryControlTable.allowEdit(true); // Overall editable, except Business Unit } }





🧠 Notes:

  • DimensionEntryControlTable refers to the dimension control used on your form.

  • This customization is typically done on the form's init() method or inside a controller class.

  • Replace "Business Unit" with any other dimension name you want to lock.


📚 Related D365FO Topics You May Like:


Post a Comment

0 Comments