Disable editing of specific financial dimensions on form -Microsoft Dynamics Finance and operations(D365FO)
Posted by : Hariharasudan kandaswamy
[FormEventHandler(formStr(Custtable), FormEventType:Initialized)]
public static void Custtable_OnInitialized(xFormRun _sender, FormEventArgs _e)
{
DimensionEntryControl dimControl = _sender.design().controlName(identifierStr(DimensionEntryControlTable));
DimensionEnumeration dimensionSetId = DimensionCache:getDimensionAttributeSetForLedger();
DimensionAttributeSetStorage dimensionAttributeSetStorage;
DimensionAttribute dimensionAttribute;
DimensionAttributeSetItem dimAttrSetItem;
const str Department= 'Department';
const str Brand= 'Brand';
dimensionAttributeSetStorage = new DimensionAttributeSetStorage();
while select dimensionAttribute
where dimensionAttribute.Name != Department // Exclude specific dimension which should be not editable
&& dimensionAttribute.Name != Brand// Exclude specific dimension which should be not editable
join dimAttrSetItem
where dimAttrSetItem.DimensionAttribute == dimensionAttribute.RecId
&& dimAttrSetItem.DimensionAttributeSet == dimensionSetId
{
dimensionAttributeSetStorage.addItem(
dimensionAttribute.RecId,
dimensionAttribute.HashKey,
NoYes::Yes);
}
dimControl.parmEditableDimensionSet(dimensionAttributeSetStorage.save());
}
Conclusion :
As a result department & Brand dimension are not editable in the custtable form
Comments
Post a Comment