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/

 

 

 

 
1 Comment

Posted by on February 20, 2019 in AX

 

One response to “Disable editing of specific financial dimensions on form

  1. JV

    October 5, 2021 at 8:25 pm

    Chiru’s AX knowledge is vast and his blog posts are always helpful. Looking forward to more posts 🙂

     

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 )

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

 
Azure Integration services for Dynamics 365

Azure Integration services for Dynamics 365 Unified Operations, Logic Apps, Azure Functions, REST

D365 FinOps

Technical and Functional Blog

Sunny's Blog on Dynamics AX

Exploring AX2012 and initiating knowledge sharing

Microsoft Dynamics 365 Blog

By Sandeep Chaudhury, Specialist in Microsoft Business Applications focused on Service and Project centric Organizations

D365FO/ AX Tips and Tricks

This blog is to help with AX issues

Moving on to D365 Finance and Operations

This blog is to help with AX issues

Dynamics AX Daily

This blog is to help with AX issues

%d bloggers like this: