Skip to main content

How to disable particular Financial Dimension on Desired form

Sometimes we want to disable particular financial dimension for purchase requisition line or any other form. To achieve that we need to write code on OnInitialized event handler of the required form. please follow the steps to achieve this functionality.

  1. Go to desired form and make note of control that is used for financial dimension(in our case Purchtable form and DimensionEntryControlLine control name).


  2. Now go to desired form(Purchtable in our case) and select OnInitialized event handler as follows and paste it in your class.


  3. write following code in the event handler class and provide Name field value (dimension which should be disabled) as well as DimensionEntryControl name and build the project.

    code :-
  4.  1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    class PurchTableEventHandler
    {
        
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        [FormEventHandler(formStr(PurchTable), FormEventType::Initialized)]
        public static void PurchTable_OnInitialized(xFormRun sender, FormEventArgs e)
        {
            DimensionEntryControl dimControl = sender.design().controlName(identifierStr(DimensionEntryControlLine));
            DimensionEnumeration dimensionSetId = DimensionCache::getDimensionAttributeSetForLedger();
            DimensionAttributeSetStorage dimensionAttributeSetStorage;
            DimensionAttribute dimensionAttribute;
            DimensionAttributeSetItem dimAttrSetItem;
    
            const str itemdimension = "item";
    
            dimensionAttributeSetStorage = new DimensionAttributeSetStorage();
            while select dimensionAttribute
                where dimensionAttribute.Name != itemdimension // 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());
        }
    
    }
    
  5. final output after disabling item financial dimension in our case.


    I hope this blog was helpful to you. You can also find out more such blogs on home page and video demeonstration on my youtube channel


Comments

Popular posts from this blog

Import Database from UAT/Production to cloud-hosted or dev environment | D365 Finance and operations

Update: If following method is not working have a look at this  Changes in SQL Script to restore bacpac file for D365FO Many times to debug the Production environment issues we might need live data to address that issue in such case first of all we need to refresh the UAT/Sandbox database with the Production environments database and then afterward we need to export the UAT database to the Asset library from where we can get bacpac file for that UAT database which is then to be imported in your cloud-hosted or one-box environment. This blog and video demonstration will help you to restore your production or UAT database to a cloud-hosted environment. Step 1: Rename existing db  In this step, we need to rename the existing AxDB for safety purposes. Just go to the SSMS application and execute the following command:-   ALTER DATABASE [ip_ent_site] SET SINGLE_USER WITH ROLLBACK IMMEDIATE GO ALTER DATABASE [ip_ent_site] MODIFY NAME = [ip_ent_site_new] GO ALTER DATABASE [ip_ent...

Changes in SQL Script to restore bacpac file for D365FO

There are changes in SQL db import it needs additional parameters now  Connection Security Improvements in SqlPackage 161 | Microsoft Community Hub otherwise it will throw following error *** Changes to connection setting default values were incorporated in a recent release.  More information is available at https://aka.ms/dacfx-connection *** Error importing database:Could not import package. Unable to connect to target server 'localhost'. Please verify the connection information such as the server name, login credentials, and firewall rules for the target server. A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The certificate chain was issued by an authority that is not trusted.) The certificate chain was issued by an authority that is not trusted. *** The settings for connection encryption or server certificate trust may lead to connection failure if the server is not properl...