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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

adding a new query object by name, and use data method by name in business logic.

(0) ShareShare
ReportReport
Posted on by

Hello,

How can I add new ax object by its name, (the object is a referred to AX-query) and than call one of its methods with parameters (also by it's name).

 

Also, How can I resolve whether the method is kind of static, private, public, display, etc.

(That shall be a query with methods ...)

Thanks :)

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Annette Theissen Profile Picture
    1,653 on at
    RE: adding a new query object by name, and use data method by name in business logic.

    Hi,

    is the following what you need?

    For this job, I added a method qrInfo to standard AX query AccountantLogisticsAddress_BR. The method just generates an info message.

       Query       q;
       QueryRun    qr;
       Object      o;
       MethodName  methodName = "qrInfo";
       ;
    
       // Create Query
       q = new Query(queryStr(AccountantLogisticsAddress_BR));
    
       // Create QueryRun and cast to an object so that we can call whatever methods
       qr = new QueryRun(q);
       o  = qr;
    
       // Make sure the method exists before calling it
       if (TreeNode::findNode('\\Queries\\' + qr.name() + '\\methods\\'+methodName))
       {
           o.qrInfo();
       }

    Hope this helps!

  • Verified answer
    Annette Theissen Profile Picture
    1,653 on at
    RE: adding a new query object by name, and use data method by name in business logic.

    Ah, sorry, there were two questions, of course :-)

    Usually, you'd resort to DictMethod or MethodInfo for this. They have several methods like "isStatic" or "accessSpecifier", but they don't seem to work in this case - or at least I don't get them to work ... sorry

        MethodInfo  methodInfo;
        methodInfo  = new MethodInfo(UtilElementType::Query, classIdGet(o), methodName);
    


  • Community Member Profile Picture
    on at
    RE: adding a new query object by name, and use data method by name in business logic.

    Thank you very much!

  • Annette Theissen Profile Picture
    1,653 on at
    RE: adding a new query object by name, and use data method by name in business logic.

    My pleasure - I like exploring, so thanks for the question :-)

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#3
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans