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 :
Finance | Project Operations, Human Resources, ...
Answered

How to traverse the controls of Form extension?

(0) ShareShare
ReportReport
Posted on by 932

Hi,

I want to get the controls of formRun, I use this approch to get all controls of standard and extension form.

Then I want to get the path of each control.

It is possible to use this approch in D365 Fo?

Thanks.

I have the same question (0)
  • WillWU Profile Picture
    22,361 on at

    Hi Basma,

    You can copy the form event handler and write the following codes to get every control.

    You can right click a control and select Addins - Copy full path  to get the path.

    Why do you want the path? I think it's enough to know the form name and the control name.

    [FormEventHandler(formStr(ProdTableListPage), FormEventType::Activated)]
        public static void ProdTableListPage_OnActivated(xFormRun sender, FormEventArgs e)
    
        {
            int controlcount;
            for(int i=1 ; i<=sender.design().controlCount();i  )
            {
                controlcount=  sender.design().controlCount();
                sender.design().controlNum(i);// get every control
            }
    
        }

  • BASMA Profile Picture
    932 on at

    Hi,

    Thanks WillWU

    I need the path of each control in other task.

    It is possible to get the path of the form then the controls?

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

    Hmm, so what it the actual requirement? What business problem you're trying to solve?

    Understanding the requirement will allow us to give you relevant answers and maybe to suggest a better approach than you've decided to implement it.

  • BASMA Profile Picture
    932 on at

    Hi Martin,

    My requirement is to save all forms with its controls into table  ,then create tree with these elements.

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

    That's your technical design - but what's the business problem? What you'll do with the data?

    Aren't you interested more in form definition than a particular running form (= a FormRun instance that you asked about)?

  • BASMA Profile Picture
    932 on at

    I want to use dat in tree.

    FormRun let me get all the controls of extension forms. But I don't know to browse form with its extensions to get all controls.

    I use this code:

    void initEUKSecurityForm()
            {
                
    
                Form                    myForm;
                Args                    args;
                FormRun                 formRun;
                formBuildDesign         design;
                TreeNode                formControl;
                
                args = new Args();
                args.name(formStr(DirPartyTable));
                formRun = classfactory.formRunClass(args);
                myForm = formRun.form();
                design = myForm.design();
               
                formNode=TreeNode::findNode(myForm.treeNodePath());
                initEUKSecurityFormControl(formNode,levelId,myForm.name());
                
            }

    void initEUKSecurityFormControl(TreeNode _formNode, int _levelId, str _forname)
            {
                
               
                Object                  formControl;
                TreeNode                controlNode = TreeNode::findNode(#FormsPath   #doubleAntiSlash   _formNode.treeNodeName()   #doubleAntiSlash   #Designs   #doubleAntiSlash   #DesignList);
                TreeNodeIterator        iteratorControl =  controlNode.AOTiterator();
                TreeNode                childControlNode = iteratorControl.next();
                while(childControlNode)
                {
                    
                    elementName = findProperty(childControlNode.AOTgetProperties(),#PropertyName);
                    elementPath = childControlNode.treeNodePath() ;
                    childControlNode = iteratorControl.next();
                }
            }

    But I get only the controls that exists in standard form

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

    You could use the new metadata API, for instance, but that's a very different question than the topic of this thread ("How to traverse the controls of FormRun").

    I can't say which approach you need unless you explain what you're trying to achieve. Even your two approaches, if they worked, would give you different results in some cases. Think of form controls added at runtime...

  • BASMA Profile Picture
    932 on at

    I tell you what is the requirement of this data : use this data into tree.

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

    Sorry, there is nothing more I can do for with this kind of specification.

    If this all you've got from your customer, you should go back to them and ask what they actually need from the business perspective. First collect the requirements, then think about how to solve the problem from both the functional and technical perspective. Only then, if you realize that it requires a customization, there will be time to start coding.

  • BASMA Profile Picture
    932 on at

    Hi Martin,

    have you any idea about how to get all controls of  form extension ?

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 559 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans