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)

x++ get current Id in a Form

(0) ShareShare
ReportReport
Posted on by 130

I'm new in ax and have a problem

I have a form with diffrent entries (Id, Name etc..) and a Button.

Click on the button will open a new class to calculate.

Now I want to get the current id, form the form to the class.

click Method:

    void clicked()

   {

    NewClass newclass; ; super();

   NewClass ::new("Id123");

   newclass.method();

   }

The string of "id123" should be the current id from the form, i have selected.

If i use select table.. I will get any id, and not the selected. The class have a parm method with a parameter.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    Hey Littleben,

    I think you can use the DictClass class for your request.

    It gives you the possibility to call classes on a dynamical way.

    This example in the link gives you a good start:

    msdn.microsoft.com/.../dictclass.callobject.aspx

    Greetings,

  • Community Member Profile Picture
    on at

    BTW: A form doesn't have an ID.

    So your approach to send a parameter to let the class know what form was used needs to be via a different property.

    A form can be called via the ClassFactory.formRunClass method.

    The parameter for this method are Arguments which needs to be filled with a formName.

  • Verified answer
    Martin Dráb Profile Picture
    237,904 Most Valuable Professional on at

    Your clicked() method should look more like this:

    void clicked()
    {
        NewClass newClass = new Class();
        newClass.parmId(CurrentId.text());
        newclass.method();
    }

    The code assumes that the form control is called CurrentId and you've set its AutoDeclaration property to Yes.

    But if the control is bound to a data source (as "If i use select table" suggests), you could pass the whole record and maybe avoid any code in clicked() by moving it to main() method of the class. Please tell us whether the control is linked to a database field or not.

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