Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

How ti get the new fields which is added in standard table in AX 2012 R3 through code

Posted on by 5,901

Hi all,

Can you please let me know I wants to get the new  fields which is added in standard table in AX 2012 R3.

Could please send me the sample code to get the list of table with new fields. That I need to send to customer.

Please give me more shed on this. 

Thanks!

  • @rp@n Profile Picture
    @rp@n 5,901 on at
    RE: How ti get the new fields which is added in standard table in AX 2012 R3 through code

    Thanks Nikoloas,

    Its working for me

  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How ti get the new fields which is added in standard table in AX 2012 R3 through code

    For me it works. Perhaps you just need to recompile your job.

    However the infolog printing causes an error because we did not initialize DictField.

    I fixed it still a bit.

    By the way, next time when you share code, could you please click "Use rich text formatting" -> "Insert" -> "Code". It's much easier to read that way. Thanks!

    static void GDTlistTableFields(Args _args)
    {
        UtilEntryLevel utilEntryLevel;
        UtilIdElements utilfield;
        DictField dictField;
        
    
        while select parentId, utilLevel,recordType, Name, id from utilfield
        where utilfield.recordType == UtilElementType::TableField
        && utilfield.utilLevel == UtilEntryLevel::cus
        && utilField.ParentId == tableNum(CustTable)
        {
            info(strFmt("%1: %2 - %3", utilfield.utilLevel, tableId2name(utilfield.parentId), utilfield.name));
        }
    }

  • @rp@n Profile Picture
    @rp@n 5,901 on at
    RE: How ti get the new fields which is added in standard table in AX 2012 R3 through code

    Hi Nikoloas,

    i ran that and debugged also. 

    static void GDTlistTableFields(Args _args)
    {
    UtilIdElements utilfield;
    DictField dictField;

    while select parentId, utilLevel,recordType, Name, id from utilfield
    where utilfield.recordType == UtilElementType::TableField
    && utilfield.utilLevel == UtilEntryLevel::cus
    && utilField.ParentId == tableNum(CustTable)
    {

    info(strFmt("%1: %2 - %3", utilfield.utilLevel, tableId2name(utilfield.parentId), dictField.name()));
    }
    }

    here && utilfield.utilLevel == UtilEntryLevel::cus

    it's returned  utilfield.utilLevel = sys

    then it's came out from loop without output.

    TABLECUS.jpgTABLECUS.jpg

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How ti get the new fields which is added in standard table in AX 2012 R3 through code

    Sure, just add criteria in the select statement:

        while select parentId, utilLevel, Name, id from utilfield
            where utilfield.recordType == UtilElementType::TableField        
            && utilfield.utilLevel  == UtilEntryLevel::cus
            && utilField.ParentId == tableNum(MyTable)

  • @rp@n Profile Picture
    @rp@n 5,901 on at
    RE: How ti get the new fields which is added in standard table in AX 2012 R3 through code

    Thanks Nikoloas,

    i ran that , it's hanged basically. i think the reason was it's seraching for all tables in AOT. is it possible to pass one by one table?

    Please give me more shed on his.

    thanks!

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How ti get the new fields which is added in standard table in AX 2012 R3 through code

    Actually you can just use the code from my previous link almost as it is. Just remove the part where it searches only for certain data type.

    I didn't test it myself but the code below should show you all table fields from CUS layer. 

    static void listTableFields(Args _args)
    {
        UtilIdElements      utilfield;     
        DictField           dictField;       
     
     
        while select parentId, utilLevel, Name, id from utilfield
            where utilfield.recordType == UtilElementType::TableField        
            && utilfield.utilLevel  == UtilEntryLevel::cus
        {
      
            info(strFmt("%1: %2 - %3", utilfield.utilLevel, tableId2name(utilfield.parentId), dictField.name()));
        }
    }

  • @rp@n Profile Picture
    @rp@n 5,901 on at
    RE: How ti get the new fields which is added in standard table in AX 2012 R3 through code

    Thanks Andre,

    Shall i use Utilelements and UtilDelements in below code ? how ??

    static void Job1(Args _args)

    {

       SysDictTable    dictTable = new SysDictTable(tableNum(PurchLine));

       SysDictField    dictField;

       TreeNode        treeNode;

       FieldId         fieldId = dictTable.fieldNext(0);

       while (fieldId)

       {

           dictField = dictTable.fieldObject(fieldId);

           if (dictField.isSql() && !dictField.isSystem())

           {

               treeNode = dictField.treeNode();

               info(strFmt("%1 | %2 | %3",

                   dictField.name(),                                               // Field name

                   treeNode.AOTgetProperty("Label"),                               // Label id

                   SysLabel::labelId2String(treeNode.AOTgetProperty("Label"))));   // Label string

           }

           fieldId = dictTable.fieldNext(fieldId);

       }

    }

    Please give me more shed on this.

    hanks!

  • Verified answer
    André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,240 Super User 2024 Season 2 on at
    RE: How ti get the new fields which is added in standard table in AX 2012 R3 through code

    Hi @rp@n,

    There are also system tables called UtilElements and UtilIDElements which can give the information of fields and the layer.

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How ti get the new fields which is added in standard table in AX 2012 R3 through code

    Here's one more blog that shows how to find elements by layer: community.dynamics.com/.../x-cross-reference-for-extended-data-types-1618632832

  • @rp@n Profile Picture
    @rp@n 5,901 on at
    RE: How ti get the new fields which is added in standard table in AX 2012 R3 through code

    Kindly suggest anyone please

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans