Disable editing of specific financial dimensions on form

The form control “DimensionEntryControl” has a method called “parmEditableDimensionSet” which sets only a specific dimension set as editable. Thus, by excluding financial dimensions from the dimension set, it is possible to make specific dimension not editable.

First, a dimension set storage needs to be created. After that, each financial dimension will be added to the dimension set storage excluding the dimensions which should not be editable. At the end, the dimension set storage will be passed to the mentioned parm-method “parmEditableDimensionSet” which then only sets the dimensions in the dimension set storage as editable.

Below is an example which implements the code in the form event handler “OnInitialized” to make dimension not editable upon calling a form.

[FormEventHandler(formStr(SalesTable), FormEventType:Initialized)]
public static void SalesTable_OnInitialized(xFormRun _sender, FormEventArgs _e)
{
    DimensionEntryControl dimControl = _sender.design().controlName(identifierStr(DimensionEntryControlTable));
    DimensionEnumeration dimensionSetId = DimensionCache:getDimensionAttributeSetForLedger();
    DimensionAttributeSetStorage dimensionAttributeSetStorage;
    DimensionAttribute dimensionAttribute;
    DimensionAttributeSetItem dimAttrSetItem;

    const str contractNumber = 'ContractNo';
    const str contractType = 'ContractType';

    dimensionAttributeSetStorage = new DimensionAttributeSetStorage();

    while select dimensionAttribute
        where dimensionAttribute.Name != contractNumber // Exclude specific dimension which should be not editable
            && dimensionAttribute.Name != contractType // 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());
}

As a result, the dimension fields “ContractNo” and “ContractType” are no longer editable on the sales order form.

findim