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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Get the query from view.

(0) ShareShare
ReportReport
Posted on by

Hello,

Is there any way to get the query object from view object?

(i.e get the query that represented the query behind the view: DirPartyPostalAddressView)

 

Thanks :)

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    You can analyze the view definition in AOT. The actual view in SQL Server obviously doesn't know anything about any query in Dynamics AX.

  • Community Member Profile Picture
    on at

    The view is built in AX AOT.

    I need some X++ code to figure out what are the objects behinds the DirPartyPostalAddressView object (it is a view, but also an object in AOT), and I can go on from that point.

    I see that there is a query object (not all the views), so I need to get that object.

    Thanks :)

  • dekaasboer Profile Picture
    1,530 on at

    Do you have database access on your enviroment?

    For me the simplest method has allways been to look the view up in ssms.

    If there is a easier way I would shure like to know.

    Your view btw:

    CREATE VIEW [dbo].[DIRPARTYPOSTALADDRESSVIEW] AS SELECT T1.PARTY AS PARTY,T1.RECID AS PARTYLOCATION,T1.ISPRIMARY AS ISPRIMARY,T1.ISLOCATIONOWNER AS ISLOCATIONOWNER,T1.ISPRIMARYTAXREGISTRATION AS ISPRIMARYTAXREGISTRATION,T1.PARTITION AS PARTITION,T1.RECID AS RECID,T2.PARTITION AS PARTITION#2,T2.LOCATIONNAME AS LOCATIONNAME,T2.ADDRESS AS ADDRESS,T2.STREETNUMBER AS STREETNUMBER,T2.STREET AS STREET,T2.CITY AS CITY,T2.ZIPCODE AS ZIPCODE,T2.STATE AS STATE,T2.COUNTY AS COUNTY,T2.COUNTRYREGIONID AS COUNTRYREGIONID,T2.DISTRICT AS DISTRICT,T2.POSTBOX AS POSTBOX,T2.BUILDINGCOMPLIMENT AS BUILDINGCOMPLIMENT,T2.TIMEZONE AS TIMEZONE,T2.LONGITUDE AS LONGITUDE,T2.LATITUDE AS LATITUDE,T2.LOCATION AS LOCATION,T2.VALIDFROM AS VALIDFROM,T2.VALIDTO AS VALIDTO,T2.COUNTRYCURRENCYCODE AS COUNTRYCURRENCYCODE,T2.ISPRIVATE AS ISPRIVATE,T2.DISTRICTNAME AS DISTRICTNAME,T2.POSTALADDRESS AS POSTALADDRESS,T2.ISOCODE AS ISOCODE,T2.STREETID_RU AS STREETID_RU,T2.HOUSEID_RU AS HOUSEID_RU,T2.FLATID_RU AS FLATID_RU,T2.BUILDING_RU AS BUILDING_RU,T2.APARTMENT_RU AS APARTMENT_RU,T2.PRIVATEFORPARTY AS PRIVATEFORPARTY,T2.XRECID_LOGISTICSPOSTALADDRESS AS XRECID_LOGISTICSPOSTALADDRESS,T2.XRECVERSION_LOGISTICSPOSTALADDRESS AS XRECVERSION_LOGISTICSPOSTALADDRESS,T2.CITYRECID AS CITYRECID FROM  DIRPARTYLOCATION T1 LEFT OUTER JOIN LOGISTICSPOSTALADDRESSVIEW T2 ON (T1.LOCATION=T2.LOCATION AND (T1.PARTITION = T2.PARTITION)) WHERE (T1.ISPOSTALADDRESS=1)

    GO

  • Verified answer
    Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    Use the TreeNode API to analyze the view definition.

  • Community Member Profile Picture
    on at

    Thank you.

    That's what I am looking for.

    I have a code like this:

        TreeNode    treeNode;
        #AOT
    
        str s;
    
    treeNode = treeNode::findNode(#ViewsPath + '\\' + tablestr(DirPartyPostalAddressView) + '\\MetaData');
        while (treeNode)
        {
            s = treeNode.treeNodeName();
            switch(s)
            {
                case 'data sources':
                // need to get the object
                    break;
                default:
                // need to get the object
                    break;
            }
            treeNode = treeNode.AOTnextSibling();
        }
    


    I presume AOTnextSibling is not the right syntax (I am not looping through the LogisticsPostalAddress object).

    I need to get the object that is behind LogisticsPostalAddress or data sources object.

     

    Thanks :)

  • Verified answer
    Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    AOTnextSibling() is the right syntax for getting the next sibling. If you want to get something else, use another method. For example, if you want to get the first child, call AOTfirstChild(). It isn't that complicated. :-)

  • Community Member Profile Picture
    on at

    Still don't understand how create an object instance from the current treeNode as my original post.

  • Verified answer
    Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    When you know the query name, you can pass it to the constructor of the Query class (new Query('xyz')). Sorry, I thought you already knew that.

  • Verified answer
    Community Member Profile Picture
    on at

    For query - I figure out how, so I succeeded getting the query object, but when the case is on 'data sources' - I I presume I must add the datasource in code, so need to loop over all the data sources elements properties.

    I didn't see any properties iterator so I can loop through.

    Thanks :)

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans