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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Traverse into the all nodes of the form in D365

(0) ShareShare
ReportReport
Posted on by 50

Hi Team,

I need some help to traverse into the each and every nodes of the form to get the control details through X++ code.

If anyone have come across this please suggest for the resolution.

Thanks in advance

Regards,

Alex Jones AX

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,990 Most Valuable Professional on at

    I've published an example on my blog.

    Here is the code:

    using Microsoft.Dynamics.AX.Metadata.MetaModel;
     
    class MetadataDemo
    {        
        public static void main(Args _args)
        {        
            AxForm form = Microsoft.Dynamics.Ax.Xpp.MetadataSupport::GetForm(formStr(SysUserSetup));
            new MetadataDemo().showControlNames(form.Design);
        }
     
        private void showControlNames(IFormControlCollection _control)
        {
            var controlEnumerator = _control.Controls.GetEnumerator();
     
            while (controlEnumerator.MoveNext())
            {
                AxFormControl control = controlEnumerator.Current;
                if (control is IFormControlCollection)
                {
                    this.showControlNames(control as IFormControlCollection); // Recursion
                }
                else
                {
                    info(control.Name);
                }
            }
        } 
    }
  • Jone91 Profile Picture
    50 on at

    Thanks martin.

    Now i can able to fetch the control details and also i need to fetch the values from the controls.

    is it possible to fetch the values from the controls ?

    Thanks in advance.

    Regards,

    Alex Jones AX

  • Martin Dráb Profile Picture
    237,990 Most Valuable Professional on at

    What do you mean by values of controls? What's the value of a group control, for example?

    Are you now talking about business data at runtime, instead of analyzing the structure of the form metadata?

    Maybe you should start with an explanation of what business problem you're trying to solve.

  • Jone91 Profile Picture
    50 on at

    Hi Martin,

    I will explain the requirement in detail.

    I need traverse into the each and every nodes of the form to get the control details through X++ code.

    For example, if we take CustParameters form means,from the form I need to display the Tab Name, Control Name and Control Value in a word document.

    Now I can able to fetch the Tab Name and Control Name from the code snippet you had provided.

    I need to display the details in the below format.

    Tab Name Control Name Control Value
    General  Minimum Reimbursement 10.00

    6428.Screen1.jpg

    Kindly assist me to reach the solution.

    Thanks in advance.

    Regards,

    Alex Jones AX

  • Martin Dráb Profile Picture
    237,990 Most Valuable Professional on at

    Why would you ever do it? Why don't you simply look at table fields?

    Again, I would be interested in what business problem you're trying to solve. You keep talking about the technical solution you've chosen, but maybe it's not the right solution of the business problem.

  • Puneet Darji Profile Picture
    168 on at

    Hi Alex,

    You may try out Task recorder feature. It will generate similar document for you.

    Regards:

    Puneet Darji

  • Suren_G Profile Picture
    252 on at

    Hi, How can we get the control properties through code. Like the control's label, datasource etc?

    Thanks!

  • Martin Dráb Profile Picture
    237,990 Most Valuable Professional on at

    Yes, you can. If you're talking about a running form, simply get a reference to a FormControl object and call its methods.

    If you mean the metadata API, look at how I accessed control.Name property in my code above. You can use the same approach to get values of other properties.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans