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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Dynamic queries

(0) ShareShare
ReportReport
Posted on by 125

I've a table ID and I need to query aseveral fields and methods on this Table. It is all dynamic, both the table Id and the list of fields and methods.

What is the best way to get the needed table information.

Thanks & Happy New Year

*This post is locked for comments

  • Joris dG Profile Picture
    17,782 on at

    To get table information (metadata), you can use the Dict* classes...

    So start with DictTable class, which can get you dictfield, dictindex, dictmethod, etc...

  • Suggested answer
    Amir Nazim Profile Picture
    5,994 on at

    Hi,

    addition on answer.

    you will find methods in DictTable class to access the fields, methods, properties, indexes etc of any table based on TableId

    Inorder to select the record you need to use the simple code below

       Common common;
       DictTable dictTable = new DictTable(_tableId);
       ;
       common = dictTable.makeRecord();
       select firstonly  common;

    InOrder to access any field from filled common buffer, use simple code below

       print common.(fieldNum(LedgerPeriod, PeriodStart));

    Thanks
    Amir
    https://msdax.wordpress.com

  • Oren Ben-Meir Profile Picture
    125 on at

    Thanks for your replies.

    I see how to get a field that is part of the table but how can I get a display method value?

    How can I invoke the method dynamically?

  • Amir Nazim Profile Picture
    5,994 on at

    Hi,

    This is prety easy to you can call the table level method using method
    public anytype callObject(...)


    Here the example excerpt from the dynamics ax documentation

    {
        Dicttable         dictTable;
        int               onlineTime;
        Common            common;
        str               resultOutput;
        ExecutePermission perm;
        ;
       
        perm = new ExecutePermission();
        dictTable= new DictTable(tablenum(SysUserLog));
        if (dictTable != null)
        {
            common = dictTable.makeRecord();
     
            // Grants permission to execute the
            // DictTable.callObject method. DictTable.callObject runs
            // under code access security.
            perm.assert();
     
            onlineTime   = dictTable.callObject("onlineTime", common);
            resultOutput = strfmt("User online time is %1", onlineTime);
            print resultOutput;
            pause;
        }
       
        // Close the code access permission scope.
        CodeAccessPermission::revertAssert();
    }

    Thanks
    Amir
    https://msdax.wordpress.com

     

     

  • Verified answer
    Amir Nazim Profile Picture
    5,994 on at

    Hi,

    This is prety easy to you can call the table level method using method
    public anytype callObject(...)


    Here the example excerpt from the dynamics ax documentation

    {
        Dicttable         dictTable;
        int               onlineTime;
        Common            common;
        str               resultOutput;
        ExecutePermission perm;
        ;
       
        perm = new ExecutePermission();
        dictTable= new DictTable(tablenum(SysUserLog));
        if (dictTable != null)
        {
            common = dictTable.makeRecord();
     
            // Grants permission to execute the
            // DictTable.callObject method. DictTable.callObject runs
            // under code access security.
            perm.assert();
     
            onlineTime   = dictTable.callObject("onlineTime", common);
            resultOutput = strfmt("User online time is %1", onlineTime);
            print resultOutput;
            pause;
        }
       
        // Close the code access permission scope.
        CodeAccessPermission::revertAssert();
    }

    Thanks
    Amir
    https://msdax.wordpress.com

     


     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans