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

Announcements

No record found.

News and Announcements icon
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 506
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)
  • André Arnaud de Calavon Profile Picture
    303,674 Super User 2026 Season 1 on at
    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?
  • D365FO Junior-Dev Profile Picture
    506 on at
    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.
  • D365FO Junior-Dev Profile Picture
    506 on at
    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
    506 on at
    Hello everyone,
    Is there any other solution to achieve that restriction on BudgetCode FD?
    Thanks!
  • Verified answer
    Martin Dráb Profile Picture
    239,029 Most Valuable Professional on at
    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().

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 617

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 461 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 298 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans