Skip to main content

Disable editing of specific financial dimensions on form

[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= 'ContosoDept';
const str CostCenter= 'ContosoCenter';

dimensionAttributeSetStorage = new DimensionAttributeSetStorage();

while select dimensionAttribute
where dimensionAttribute.Name != Department
&& dimensionAttribute.Name != CostCenter
join dimAttrSetItem
where dimAttrSetItem.DimensionAttribute == dimensionAttribute.RecId
&& dimAttrSetItem.DimensionAttributeSet == dimensionSetId
{
dimensionAttributeSetStorage.addItem(
dimensionAttribute.RecId,
dimensionAttribute.HashKey,
NoYes::Yes);
}

dimControl.parmEditableDimensionSet(dimensionAttributeSetStorage.save());
}