RSS

Disable editing of specific financial dimensions on form

20 Feb

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

Happy daxing!

Courtesy: https://d365dev.com/2018/04/20/disable-editing-of-specific-financial-dimensions-on-form/

 

 

 

Advertisements
 
Leave a comment

Posted by on February 20, 2019 in AX

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

 
Microsoft Dynamics 365 Blog

Blog by Sandeep Chaudhury, A Microsoft Enthusiast

Sunny's Blog on Dynamics AX

Exploring AX2012 and initiating knowledge sharing

Dynamics 365 For Finance and Operations Blog

Blog By Sandeep Chaudhury, a Microsoft enthusiast

Microsoft Dynamics AX Tips and Tricks

This blog is to help with AX issues

FT Dynamics AX blog

This blog is to help with AX issues

Dynamics AX Daily

This blog is to help with AX issues

%d bloggers like this: