Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

How to retrieve the custom attribute using Query

Posted on by 510

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

  • Ludwig Reinhard Profile Picture
    Ludwig Reinhard Microsoft Employee on at
    RE: How to retrieve the custom attribute using Query

    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

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: How to retrieve the custom attribute using Query

    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.

  • Suggested answer
    CJ Profile Picture
    CJ 510 on at
    RE: How to retrieve the custom attribute using Query

    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]

  • Suggested answer
    Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: How to retrieve the custom attribute using Query

    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.

  • CJ Profile Picture
    CJ 510 on at
    RE: How to retrieve the custom attribute using Query

    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.

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: How to retrieve the custom attribute using Query

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

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

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!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans