Santosh.'s profileDynamics AxPhotosBlogLists Tools Help

Blog


    September 29

    How to Display Table,Query field value in Xml.

     

    Hi Everyone,

    In table, query, view we have a system method as xml () which is used to display field value in Xml.  The structure of table/query is created as Xml. This method gives you the feasibility of populating the fields directly in xML without actually using the xML Classes available in AX.

    Please find the following examples below:

    Using Table:

    static void TableFieldsAsxML(Args _args)
    {
        #define.CustAccountNum('4000')
        #AOT
        #define.xmlFileName('.xml')

        CustTable   custTable;
        XmlDocument xmlDocument;
        str         _xml;
        ;

        xmlDocument = new XmlDocument();

        select firstonly custTable
            where custTable.AccountNum == #CustAccountNum;

        _xml = custTable.xml(1);
        xmlDocument.loadXml(_xml);
        xmlDocument.save(WinApi::getTempPath() +
                                         #AOTDelimiter +
                                         strins(strrem(xmlDocument.name(), '#'), #xmlFileName, strlen(xmlDocument.name()) + 1));
    }

     
    Using Query:
     

    static void QueryAsxML(Args _args)
    {
        #AOT
        #define.xmlFileName('.xml')
        #define.CustAccountNum('4000')

        Query                q;
        QueryRun             qr;
        QueryBuildDataSource qbd;
        QueryBuildRange      qbr;
        XmlDocument          xmlDocument;
        str                  _xml;
        ;

        q = new Query();
        qbd = q.addDataSource(tableNum(CustTable));
        qbr = qbd.addRange(fieldNum(CustTable, AccountNum));
        qbr.value(#CustAccountNum);
        qbd.addSortField(fieldNum(CustTable, Name));
        qr = new QueryRun(q);
        xmlDocument = new XmlDocument();
        _xml = q.xml(1);
        xmlDocument.loadXml(_xml);
        xmlDocument.save(WinApi::getTempPath() +
                                         #AOTDelimiter + 
                                         strins(strrem(xmlDocument.name(), '#'), #xmlFileName, strlen(xmlDocument.name()) + 1));
    }
    33232781.jpg
     
    This way you can use the system xml() function view a given file in xml.
    September 18

    AX Add-ins

     
    Coming Soon..................................
     
    Add-ins which are useful to Developer
     
    1) Listing Mandatory Fields in tables without actually traversing to AOT.
     
    2) AOT Browser - Without Manual UI Interaction.Sarcastic
     
    September 09

    Error occurred executing stored procedure when creating session for the AOS

     

    Please Note:  All this code snippets are a result of some development that came up from time to time. Please feel free to use them for your own use with discretion.

     

    In AX2009 I tried manually creating DB and pointing Dynamics server to the created DB. When trying to start the AX services I ended up facing following errors.

    err100.jpg

     

    On viewing the event viewer under Application you will clearly see there is a login failure issue

    even.jpg 

    So you need to manually change the log on password under Dynamics AX service properties. Again when AX service was restarted there was another error.

    err100.jpg

     

    In the event viewer you’ll see the following error

    eves.jpg 

    What is the error all about?

    When AX is installed through setup.exe, stored procedures are internally created for the Database. The two stored procedures that gets created are

    ·         CREATESERVERSESSIONS

    ·         CREATEUSERSESSIONS à This creates the User Session

    So when DB is created manually in SQL, the stored procedure is not available because of which AX service is not started successfully.

     

    Solution:

    For the DB which are created manually make sure you create the stored procedure successfully in order to point to AX server.

     

    STORED PROCEDURE FOR CREATESERVERSESSIONS

    http://cid-264a0056cbcbb1d3.skydrive.live.com/self.aspx/.Public/CREATESERVERSESSIONS.sql
     

    STORED PROCEDURE FOR CREATEUSERSESSIONS

    http://cid-264a0056cbcbb1d3.skydrive.live.com/self.aspx/.Public/CREATEUSERSESSIONS.sql 

     

    Run the stored procedure SCRIPTS and then try to restart AX service. You’ll successfully be able to point to the newly created Database.