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)

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

I have the same question (0)
  • Verified answer
    Kyle Wascher Profile Picture
    185 on at

    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();
    }
    

     

  • NR-11010513-0 Profile Picture
    2 on at

    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

  • Kyle Wascher Profile Picture
    185 on at

    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.

  • Harshad Duddekunta Profile Picture
    131 on at

    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

     

     

  • NR-11010513-0 Profile Picture
    2 on at

    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...

  • MukeshHirwani Profile Picture
    1,180 on at

    Hi,

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

  • Suggested answer
    Harshad Duddekunta Profile Picture
    131 on at

    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>

  • Community Member Profile Picture
    on at

    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

  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    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).

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