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)

ControlClasses - Forms and Form's Objects

(0) ShareShare
ReportReport
Posted on by 3,850

Hello

I have tried to read about ControlClasses and the code who is behind it, and how it connects to the objects in forms.

I cant understand how some VAR's and EDT in Classes can be connected with form Objects.

Do I understand things right that the ground is based on EDT:

I have Form Object with text who is combined with EDT named MyEDT.

I have Control class with that form who have a method based on MyEDT and in that method is variable who will be assigned default value == 00

So, if I set MyEDT on a Form Object, and use MyEDT in method with vars, then the method will be signed with value and that value appear in the form object because they have same EDT

Cn someone explain it

*This post is locked for comments

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

    EDT is completely irrelevant in this situation, you just need compatible or at least convertible types. Control names are irrelevant either, they're just identifiers. No logic will be executed just by using any particular naming pattern.

    Don't look for any magic and just think about objects and method calls. If you want to set a value to a form control based on a class, you have two basic options:

    1) The form has a reference to the class, calls its method and set the return value to a form control.

    2) The class has a reference to the form control and calls its method (e.g. FormRealControl.realValue()) to set a value.

    It would help if you provided more details about what you're trying to achieve.

  • Sandri Profile Picture
    3,850 on at

    Hello Martin.

    -My situation in detail is like this.

    -I have a textbox in form who display two digits.

    -I have a method in Class who generate a variable and set a value into that variable.

    -I want the textbox who is in a form display the value who was set in the variable in the class.

    What I don't understand:

    -When I look over ProdTableForm Class and ProdTable Form I cant see any references on each form object who point directly to a variable in the class or particular method who generate a value.

    -I have look over a lot of textboxes and they have for example no methods who point to a particular part on a class to get informations, but I know that the values that the form object display is from particular Variable who is on particular method in the ProdTableForm Class - but I can't see how the form object get the method call in the Class.

    -I don't cant to write a method in each Form Object where I generate a method in a Class because I can't see that isn't a way to do that in another forms and control classes. Therefore it's lot of work to write a form method to point to a Class method.

    -I need to know what is most relevant way to point a form object to a Class method without having to wirte a method in each form object.

    -Is the identification between form objects and calss methods the name of the class method?

    -Do I name the form Object and use the form object name as a variable in the class method so the object can display the value in the variable?

    -Hope you understand me!

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

    ProdTableForm uses two ways:

    a) it exposes some methods that are called from the form (the form holds a reference to the class), e.g. checkGanttEnabled().

    b) it refers to form buffers / data sources (received from the form in setDatasources(). In some cases, it set values to fields, e.g. ProdTable.InventDimId in handleProdTableWritePreSuper().

    If you don't understand how form controls are bound to data source, take a look at it. It's very important.

  • Sandri Profile Picture
    3,850 on at

    Do You have any blog post or training materials that I can look at?

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

    The documentation is on MSDN - see Client [AX 2012]. Training materials for development courses are useful too (available on CustomerSource/PartnerSource).

  • Sandri Profile Picture
    3,850 on at

    Thanks Again Martin.

    -I have read over it briefly and I'm trying to get over the problem that I have.

    -I need a little answer to the followed comment:

    1) I have a form with Grid object (who represent a table).

    2) The form have TextBox (who hold basic text).

    3) User write some text into that TextBox and press to OK button.

    4) The value in the TextBox will be copied into one field in ALL records who is displayed in the GRID.

    -Because the TextBox value is "one value for all fields in all records" I think its un-logical to have the value in the TexBox based in one field in seperate table from the Grid and copy the value between tables.

    -Thinking about it more and more I thing its much more relevant to use a Str VAR who is based in a method in a Class.

    -I can make this happend with two seperate tables, but the second table is just with one record and one field who is that textBox value. But it look little bit unprofessional.

    -What is your opinion on this? use a Str VAR in a class who is called buy TextBox in the form? If so how can I do that?

    -But if you think a seperate table with only one record and only one field should be used - please confirm.

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

    It's all about objects and methods. Seriously.

    You have your form, which is technically an instance of a class. It has a reference to a form control called TextBox, which is an instance of FormStringControl class. If you want to know state of an object, you have to call a method. Specifically, if you want to know TextBox's value, call its text() method (you have to set its AutoDeclaration property to Yes to be able to use its name directly in X++).

    And you have another class and want to pass a value inside it. What should you do? Call a method, of course. And because you want to pass some data, the method needs a parameter.

    Note that you don't need to define any variable to hold the value - it's already held in the FormStringControl instance. Only when you want to use it in another object than the form, you have to pass there either the value or a reference to the control.

  • Sandri Profile Picture
    3,850 on at

    Hi Martin, thanks a lot.

    -So you make me to ask one simple question more: Then I almost get the point.

    -I write a Class and I declare a instance of a class (or what you call it) Just like this:

    FormStringControl     myTextDeclairation;

    -Then I name the actual control on the form the same name: myTextDeclairation;

    I set a value to that myTextDeclaration in some class, then the form Object will display the value.

    -Is that right thinking?

  • Ivan (Vanya) Kashperuk Profile Picture
    on at

    No. You need to somehow get a hold of the instance of the form control in the handling class

    Either by passing the instance into the class after initializing it in the form, or by getting the control instance by the name of the control in the handling class itself.

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

    When you create a form control, it's an object (what else, in object-oriented programming? :)). Set its AutoDeclaration property to Yes to be able to address it directly from X++ on the form. Then you can call its text() method to set a value or read the actual value.

    If you want, you can pass the control as a method parameter to a class and save it to a variable there.

    For example:

    classDeclaration
    {
        FormStringControl myControl;
    }
    
    public void setControl(FormStringControl _control)
    {
        myControl = _control;
    }

    And you'll call it from your form like this:

    myClass.setControl(myTextBox);

    Notice that names are not significant at all. There is no need to name the variable in any particular way - what's important is the assignment, not the name.

    It seems to my that your problem is not about AX - you have to learn how to use methods and objects first. You really have to get these basics before trying anything more complex.

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
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans