Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

AIF Change Tracking

(0) ShareShare
ReportReport
Posted on by 2

Has anyone managed to successfully configure AIF services for change tracking?

I have enabled both change tracking at a Database-level and at a Table-level (CustTable). This was carried out directly in SQL.

When I make a change to a Customer record in the AX client, I can query the SQL change-tables directly and view the changed records.

However, when I try the execute the getChangedKeys() operation on the CustCustomerServices from a .net client, the EntityKeyPage object has a PageStatus property set to 'Failure' and a PageStatusDetails property set to 'Change Tracking Disabled'.

Is there anything else I need to do to enable change tracking, is this configurable from within the AX client somewhere?  The documentation (which seems fairly thin on the ground) seems to suggest that this only needs to be enabled on the database table.

http://msdn.microsoft.com/en-us/library/hh433529.aspx

 

Thanks,

Nick

 

*This post is locked for comments

  • Martin Dráb Profile Picture
    Martin Dráb 230,514 Most Valuable Professional on at
    RE: AIF Change Tracking

    Prasad, if you want to discuss your problem, please create a new thread and give us a more detailed description than just "I am facing the issue".

    You can't expect us to read your mind and give you exactly the piece of code you need to solve your particular issue (if it can be solved by a piece of code at all).

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: AIF Change Tracking

    Hi Nick,

    Hope your are doing good!!!

    I am replying to a quite old link, I am facing the issue in using "getChangedKeys()" operation from .net, if you have the sample code snippet, it would be helpful.

    Thanks in advance.

    Best Regards,

    Guruprasad

  • Suggested answer
    Harshad Duddekunta Profile Picture
    Harshad Duddekunta 131 on at
    RE: AIF Change Tracking

    Captured this through a WCF tracing tool for the getChangedKeys request to AX.

    Hope this can help you..

    <?xml version="1.0"?>

    <s:Envelope xmlns:s="schemas.xmlsoap.org/.../">

    <s:Header>

    <h:CallContext xmlns:xsd="www.w3.org/.../XMLSchema" xmlns:xsi="www.w3.org/.../XMLSchema-instance" xmlns="schemas.microsoft.com/.../datacontracts" xmlns:h="schemas.microsoft.com/.../datacontracts">

    <Company xsi:nil="true"/>

    <Language xsi:nil="true"/>

    <LogonAsUser xsi:nil="true"/>

    <MessageId xsi:nil="true"/>

    <PropertyBag xsi:nil="true"/>

    </h:CallContext>

    </s:Header>

    <s:Body xmlns:xsd="www.w3.org/.../XMLSchema" xmlns:xsi="www.w3.org/.../XMLSchema-instance">

    <ItemsServiceGetChangedKeysRequest xmlns="http://tempuri.org">

    <DocumentPaging xmlns="schemas.microsoft.com/.../DocumentPaging">

    <Bookmark xsi:nil="true"/>

    <PageSize>5</PageSize>

    </DocumentPaging>

    <_changedDateTime>2013-03-05T09:00:00</_changedDateTime>

    </ItemsServiceGetChangedKeysRequest>

    </s:Body>

    </s:Envelope>

  • MukeshHirwani Profile Picture
    MukeshHirwani 1,180 on at
    Re: AIF Change Tracking

    Hi,

    request you to provide sample XML which can be sent as an Inbound file with getChangedKeys operation.

  • NR-11010513-0 Profile Picture
    NR-11010513-0 2 on at
    Re: AIF Change Tracking

    Not sure if there's a better way, but you could always re-create the document service by reconstructing the underlying query using the actual tables rather than the views? Bit long-winded mind...

  • Harshad Duddekunta Profile Picture
    Harshad Duddekunta 131 on at
    Re: AIF Change Tracking

    Hi Kyle,

    Followed the steps mentioned in this post, and was able to use getchangedkeys method of other document services like Vendor, Transfer Order. But to send purchase id's i would like to use the getchangedkeys  Purchase Requisition Service of AX 2012.

    The main method errors out for Purchase Requisition Service. Replaced [Query: AxdPurchaseRequistion and Table: VendPurchOrderJour] these two values in the main method.

    The error is because PURCHTABLEARCHIVEDVERSIONS is a View in AX and this is not available at database level. Is there any way to make this work for Purchase Order Document Service?

    Error:

    SQL error description: [Microsoft][SQL Server Native Client 10.0][SQL Server]The object 'dbo.PURCHTABLEARCHIVEDVERSIONS' does not exist or is invalid for this operation.

    SQL statement: CREATE TRIGGER AIFTestScopeAxdPurchaseRequisitionPurchTableAllVersionsAfterDelete75e10f64c2414901901c59aa30bfa490
       ON  dbo.PURCHTABLEARCHIVEDVERSIONS
       AFTER DELETE
    AS
    BEGIN
        SET NOCOUNT ON;   
        update VENDPURCHORDERJOUR set VENDPURCHORDERJOUR.RECID = VENDPURCHORDERJOUR.RECID
        from VENDPURCHORDERJOUR
        cross join DELETED
        where
         DELETED.PURCHTABLEVERSIONRECID = VENDPURCHORDERJOUR.PURCHTABLEVERSION
    END

     

     

  • Kyle Wascher Profile Picture
    Kyle Wascher 185 on at
    Re: AIF Change Tracking

    Hi Nick,

    I'm not exactly sure how the parent-child table relationship works with change tracking. I know you can peek at what tables AX has change tracking enabled in the "AIFSQLCDCENABLEDTABLES" table, and I noticed some of the party tables are in there so it gives me some hope but I don't have an answer for this one. If you or someone else comes across this I would like to know as well.

    The data retention period for the change tracking methods (i.e. getChangedKeys) can be changed by opening up SQL Server Management Studio and going to the properties of the database, then Change Tracking. There you can set the "Retention Period" to something more appropriate for your needs. You can even make it smaller into Hours or Minutes if needed.

  • NR-11010513-0 Profile Picture
    NR-11010513-0 2 on at
    Re: AIF Change Tracking

    Hi Kyle,

    Based on your answer, I have managed to get this working. The information was excellent, many thanks!

    I am however still trying to fully get to grips with the functionality. A couple of observations;

    Changes in child tables are currently not propagating into the parent change-tables. i.e. if I make a change to the Party name, I can't see the changes when I query the CustTable. At the moment I'm not sure if this is possible or not?

    Also, I can only query the change-tables with a date no earlier than three days in the past. i.e. if I supply the getChangedKeys() method with a  date similar to 'DateTime.Now.AddDays(-4)'. The query fails with a status 'change date out of range'. This is slightly unexpected behaviour.

    Anyway, thanks again for your reply. It was very helpful.

    Regards,

    Nick

  • Verified answer
    Kyle Wascher Profile Picture
    Kyle Wascher 185 on at
    Re: AIF Change Tracking

    Hey Nick,

    I have been looking at Change Tracking for a couple weeks now, and finally today have successfully gotten it to work. The MSDN article does not help much at all, but with a little x++ knowledge and looking into the classes I found "AifChangeTrackingConfiguration". In order to be able to call the static methods on this class we must assert permissions from "AifChangeTrackingPermission".

    1. The first thing you need to do is be able to get into the Development Workspace.
    2. Once there we need to create a class, the reason we need a class is because this code needs to be executed server side. (Note the server keyword before the method)
    3. Inside the static main method we can assert using new AifChangeTrackingPermission().assert() then we can execute what static methods on "AifChangeTrackingConfiguration" we want.
    4. Hit run! (You can manually double check in SQL Managment Studio on the tables, under Properties -> Change Tracking that this worked!)
    5. Redeploy your web service (Deactivate, Reactivate)

     

    Here is an example of what I used to get getChangedKeys() working for CustCustomerService:

     

    server public static void main(Args _args)
    {
        Query _query;
        AifChangeTracking _changeTracking;
        new AifChangeTrackingPermission().assert();
    
        info(strFmt("%1", AifChangeTrackingConfiguration::isChangeTrackingEnabled()));
        // Run this first to globally enable changeTracking
        //AifChangeTrackingConfiguration::enableChangeTracking(true);
       
        // Here we are loading the query that the webservice uses (I took a wild guess to figure this out)
        _query = new Query("AxdCustomer");
        AifChangeTrackingConfiguration::enableChangeTrackingForQuery("TestScope1", _query);
        _changeTracking = AifChangeTracking::construct(_query);
        // Did we enable change tracking?
        info(_changeTracking.isChangeTrackingEnabled()? "true" : "false");
        // did we enable change tracking for this specific query?
        info(_changeTracking.isChangeTrackingEnabledForQuery()? "q:true" : "q:false");
        // redundant check... but anyways its checking if the specific table has change tracking enabled
        info(_changeTracking.isChangeTrackingEnabledForTable(tableNum(CustTable))? "t:true" : "t:false");
    
    
        // Revert the permission assert
        CodeAccessPermission::revertAssert();
    }
    

     

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,514 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans