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, ...
Suggested Answer

Add real field control dynamically in Form

(0) ShareShare
ReportReport
Posted on by 4
Hello!!
 
I have a requirement were I have to add multiple budget year (depending budget years specified on another form) and the respective budget values dynamically in a new custom form. When I try adding it using below code I get the control names on the form but respective budget value is missing. When I debug the code budget value is correctly inserted in the control but on the front end the values are not displayed. 
 
 public void run()
   {
      FormBuildDesign             formBuildDesign = form.design();
      FormBuildGroupControl       formBuildGroupControl;
      FormRealControl c;

      while (i <= countBudgetLine)
      {
         c = budgetyeargroup.addControl(FormControlType::Real, 'YearName' + int2str(i));
         c.label(conPeek(yearName,i));
         c.realvalue(conPeek(budgetAmountCon,i));
         c.registerOverrideMethod(methodStr(FormRealControl, validate), 'runTimeControlValidate');
         formBuildGroupControl = formBuildDesign.control(budgetyeargroup.id());
         i++;
      }
      super();
   }
 
Please suggest.
 
 
I have the same question (0)
  • Martin Dráb Profile Picture
    238,789 Most Valuable Professional on at
    It seems to me that that a half of your code isn't needed to demonstrate the problem. I'm would reduce it to this:
    public void run()
    {
        FormRealControl c = budgetYearGroup.addControl(FormControlType::Real, 'YearName1');
        c.label("TEST");
        c.realValue(999);
    
        super();
    }
    Do you agree?
     
    Which version of AX are you using?
  • Community member Profile Picture
    4 on at
    yes, this code snippet is enought.
    D365 f&O(10.0.37 (10.0.1725.47))
  • Martin Dráb Profile Picture
    238,789 Most Valuable Professional on at
    Moved from Dynamics AX forum.
  • Martin Dráb Profile Picture
    238,789 Most Valuable Professional on at
    It works correctly for me.
     
  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at
    It depends based on elements found in the container. 
     
    c.realvalue(conPeek(budgetAmountCon,i));
     
    At this point, do you have values in the container "budgetAmountCon" specified? Firstly, try directly assigning some value like below. Also, you can remove validation part for now.
     
    c.realvalue(123);
     
    If this is working then check about container and then validation.
  • Martin Dráb Profile Picture
    238,789 Most Valuable Professional on at
    Akshata confirmed that this code can be used to test the problem:
    public void run()
    {
        FormRealControl c = budgetYearGroup.addControl(FormControlType::Real, 'YearName1');
        c.label("TEST");
        c.realValue(999);
    
        super();
    }
    There is container involved. That was in the original code, before we simplified it to be able to focus on the actual problem and without being distracted by unrelated code.
     
    If Akshata said that the simple code worked and the actual didn't, then we'd know that the control adding and value setting isn't the actual problem and we would check things like the container (despite Akshata's claim that "the code budget value is correctly inserted").
  • Community member Profile Picture
    4 on at
    @Martin: 
    My requirement is to add multiple controls in grid but here it gets displayed one after another 
     
    when I add the controls directly to design controls 
    c1= element.design().addControl(FormControlType::Real, 'YearName' + int2str(i));
    c1.label(conPeek(yearName,i));
    c1.realValue(conPeek(budgetAmountCon,i));
     
     
    I want controls to be printed in grid format which I am able to achieve by adding controls in groupControl but here values are not getting displayed.
     
     
    c = budgetyeargroup.addControl(FormControlType::Real, 'YearName' + int2str(i+6));
    c.label(conPeek(yearName,i));
    c.realValue(conPeek(budgetAmountCon,i));
     
    @Bharani: the containers have values and even after removing the validation values are not displayed on form.
  • Martin Dráb Profile Picture
    238,789 Most Valuable Professional on at
    It's great to hear that you're now able to successfully add real controls and set their values.
     
    You never mentioned a grid before and your approach indeed can't work a grid. Grid requires columns bound to field or method.Either don't use a grid, or forget all your current code, because you'll need to design a completely different solution.

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
André Arnaud de Calavon Profile Picture

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

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 386

#3
Adis Profile Picture

Adis 259 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans