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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to retrieve the custom attribute using Query

(0) ShareShare
ReportReport
Posted on by 512

Hi,

I have an issue regarding the custom attributes that I added in SalesLine. When I am using Query, it was not included the custom attribute when I run the queryRun.

Here is the Sample Code.

-Entity [SalesLine]

    -  SalesOrderType  // Custom Attributes.

----------------------------------------------------------------------------------------------------------------

Sample Code:

Query   query;

Query  queryRun;

QueryBuildDataSource qbds;

query = new Query();

query.alloCrossCompany(true);

qbds = query.addDataSource(tablenum("SalesLine"));

qbr = qbds.addRange(fieldNum(SalesLine,SalesId));

qbr.value("= SO00001");

queryRun = new Query(query);

while(queryRun.next())

{

          SalesLine line = queryRun.get(tablenum(SalesLine));

          if(line)

         {

                       var salesorderType = line.SalesOrderType;

         }

     

}

Thank you for your reply.

Regards,

CJ

I have the same question (0)
  • Mea_ Profile Picture
    60,286 on at

    Are you sure that it hits " var salesorderType = line.SalesOrderType;" line at all ?

    It should be qbr.value("SO00001") instead of qbr.value("= SO00001");

  • CJ Profile Picture
    512 on at

    Hi ievgen,

    Yes, the filter it's working but my issue that my new attributes salesOrdertype is not there in my SalesLine when I am going to debug. I extend salesLine entity to add my new attributes.

  • Suggested answer
    Mea_ Profile Picture
    60,286 on at

    Its under "extension fields" or something like that. So in debugger you should see group that you can expand and all fields added via extensions will be there.

  • Suggested answer
    CJ Profile Picture
    512 on at

    Hi,

    There is an extension fields group like this below.

    ((Microsoft.Dynamics.Ax.Xpp.TableExtensionFields)new Dynamics.AX.Application.SalesTable.SalesTableDebuggerProxy(header).Extension_Fields).Items[1]

  • Mea_ Profile Picture
    60,286 on at

    Where are you looking at ? In the end of the day you can just write

    info(strFmt('%1', salesorderType ));

    and see if it has a value.

  • Ludwig Reinhard Profile Picture
    Microsoft Employee on at

    Good Morning Christian,

    Just wanted to follow up on this issue and ask if your issue has been resolved in the meantime.

    If it is resolved then please be so kind and provide some feedback my marking the answers as verified to let also other community members know what helped.

    Many thanks for your support.

    Best regards,

    Ludwig

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 653

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 493 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 317 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans