web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How to Customize BudgetCode in Dimension Entry Form Control

(3) ShareShare
ReportReport
Posted on by 421
Hello,
I have a custom form where I recently added line details (financial dimensions) as shown in the attached image now, I would like to customize the BudgetCode field (return some of records).
The system automatically generates a control name like this: LineDimensionEntryControl_DECValue_Budgetcode but the code I'm using is unable to find this control.
Is this approach correct, or is there another recommended way to access or customize this control?
Thank you.
 
 
 [FormEventHandler(formStr(MyFormHeader), FormEventType::Initialized)]
 public static void MyFormHeader_OnInitialized(xFormRun sender, FormEventArgs e)
 {
      
     try
     {
          
         FormRun formRun = sender as FormRun;
          
         FormStringControl budgetCodeControl = formRun.design().controlName("LineDimensionEntryControl_DECValue_Budgetcode") as FormStringControl;
         
          
         if (budgetCodeControl)
         {
             budgetCodeControl.registerOverrideMethod(
             methodStr(FormStringControl, lookup),
             methodStr(MyFormHeaderLookUp_Extension, customBudgetCodeLookup),
             formRun
         );
            
         }
         else
         {
             info("Control not found or is not a DimensionEntryControl.");
         }
     }
     catch 
     {
         info('Error...');
     }
      
 }
 

 
 
 
I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    236,172 Most Valuable Professional on at
    How to Customize BudgetCode in Dimension Entry Form Control
    You're making two mistakes:
    • Your hard-code a reference to a particular dimension, but it doesn't have to exist. Which dimensions are displayed depends on configuration.
    • You're ignoring the controller class, which is used to control behavior of dimension controls.
    I think you should create a new class inheriting from LedgerDefaultDimensionEntryController, override  applyDimensionAttributeCategorizationFiltering() (and put your logic there) and then using your class in the Controller Class property of the dimension entry control. But I would have to try it to see if applyDimensionAttributeCategorizationFiltering() behaves as I expect; please test it yourself. If it happens to be a bad idea, start your analysis from the dimension entry control, namely DimensionEntryControl.dimensionValue_lookup().
  • D365FO Junior-Dev Profile Picture
    421 on at
    How to Customize BudgetCode in Dimension Entry Form Control
    Hello everyone,
    Is there any other solution to achieve that restriction on BudgetCode FD?
    Thanks!
  • D365FO Junior-Dev Profile Picture
    421 on at
    How to Customize BudgetCode in Dimension Entry Form Control
    I could to gain control in the event but I'm now encountering the following error.
     
     #define.BUDGETCODEVALUE('LineDimensionEntryControl_DECValue_Budgetcode')
     FormStringControl budgetCodeControl = formRun.design().controlName(#BUDGETCODEVALUE) as FormStringControl;
    
     if (budgetCodeControl)
             {
                 budgetCodeControl.registerOverrideMethod(
                 methodStr(FormStringControl, lookup),
                 methodStr(MyFormHeaderLookUp_Extension, customBudgetCodeLookup),
                 formRun
             );
     


    Error:
    RegisterOverrideMethod was called twice for the same object for method 'lookup'. You can only override a method once per instance.
  • D365FO Junior-Dev Profile Picture
    421 on at
    How to Customize BudgetCode in Dimension Entry Form Control
    Hi @André Arnaud de Calavon ,
    The business requirement is that certain budget codes should not be visible in the lookup. For example any budget code that ends with "-Finance" should be excluded.
    I’ve already followed your blog post on adding financial dimensions to a custom form:
    https://dynamicspedia.com/2020/12/tips-on-ledger-default-dimension-development-on-forms/
     
     now I'm facing an issue with the control LineDimensionEntryControl_DECValue_Budgetcode It doesn’t seem to be recognize in the OnInitialized() event

    about run() method I haven't tried this one should I use run() method ?

    Any advice on how to proceed would be greatly appreciated.
  • André Arnaud de Calavon Profile Picture
    298,655 Super User 2025 Season 2 on at
    How to Customize BudgetCode in Dimension Entry Form Control
    Hi D365 FO Junior Dev,

    Can you explain the exact business requirement? It looks like the list with values in the lookup needs to be restricted. Can you tell the condition when what values will be made visible?
     
    Apart from this, have you tried extending the run() method instead of the init() method?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,352

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 810 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 616 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans