5 Replies Latest reply on Aug 18, 2016 6:48 PM by pmartin

    How do I find objects that has been changed?


      I'm creating a process that replicate the AF objects changes (including attributes data) to IBM Maximo.  These are few issues/questions that I have with FindChangedItems and FindObject (AFChangeInfo) methods

      1. How do I define the deltas. For example, If an object that has different updates during the same period of time, How do I get all the updates or the last update?
      2. How do I Identify attributes data changes? 
      3. After an object is eliminated FindObject methods returns null.  How Do I find an object after deletion?

      Any guidance will be highly appreciated.


        • Re: How do I find objects that has been changed?

          Hi Jose,


          I see this post is marked as Assumed Answered.  Did you find what you were looking for?  If so, could you share your findings with the community?

          • Re: How do I find objects that has been changed?

            Adding more content, to my previous post.

            This is the example code I have found and used for my testing; however the below code doesn't address any of the items listed on my previous post.

            1. If an object was updated more than once, the object appears more than once. I'm assuming that the last object listed is the one with all the changes.

            2. How do I know what in the object has changed. (attributes values, name, categories). Is there a way to know what has changed in the object. I was thinking using AFAudit Trail, but I have read that activating AF Audit Trail will cause performance issues. Any comments on that?

            3. If the object is deleted, this line of code "AFObject myObj = info.FindObject(myPISystem, true);" returns null, obviously since no longer exists.  Is there any other way to know which object was deleted?


            Botton line I need to keep AF and and IBM Maximo in sync, any changes in AF needs to be syncronize in IBM Maximo object model. In other to do that I need to know what has changed in AF elements, not necessary in real-time.

            //This example demonstrates getting changes made by other users
                        //  and refreshing the objects.
                        // Get the System and Database
                        PISystem myPISystem = new PISystems().DefaultPISystem;
                        AFDatabase myDB = myPISystem.Databases.DefaultDatabase;
                        object sysCookie, dbCookie;
                        myPISystem.FindChangedItems(true, int.MaxValue, null, out sysCookie);
                        myDB.FindChangedItems(true, int.MaxValue, null, out dbCookie);
                        // Wait for changes to be made...
                        // Find changes made by other users.
                        List<AFChangeInfo> list = new List<AFChangeInfo>();
                        list.AddRange(myPISystem.FindChangedItems(true, int.MaxValue, sysCookie, out sysCookie));
                        list.AddRange(myDB.FindChangedItems(true, int.MaxValue, dbCookie, out dbCookie));
                        // Refresh objects that have been changed.
                        AFChangeInfo.Refresh(myPISystem, list);
                        // Find the objects that have been changed.
                        foreach (AFChangeInfo info in list)
                            AFObject myObj = info.FindObject(myPISystem, true);
                            Console.WriteLine("Found changed object: {0}", myObj);


              • Re: How do I find objects that has been changed?
                Mike Zboray

                1. You can't really get the intermediate versions unless they are being saved using AF versions. You always get the most recent version otherwise.

                2. This depends on what attribute value changes you are looking for, but non-DataReference attributes would show up an Update type change to the Element. If the attribute is not a configuration item (IsConfigurationItem=false) then IsValueUpdate is set to true on the change info, otherwise updating the attribute requires a checkin of the element and it is never a "value update". If it has a data reference (e.g. PI Point) then the AFDataPipe is mechanism to use to receive updates, assuming the data reference supports this. There isn't anything more granular to tell you which properties on the object changed.

                3. There is no way to get deleted objects. They are no longer in the database.


                The FindChangedItems API isn't really designed to deliver every intermediate version of every object. Its only really suitable for telling you which items have been changed and its up to you to decide if anything significant changed.


                FWIW handling changes like this comes up with Notifications. We track the state of event frames we are notifying the user of. Every time there is a change to an event frame we inspect the event frame for important changes (e.g. it is closed). If the change is important, then we write down that we've seen it and do something like notify the user, if needed.

                • Re: How do I find objects that has been changed?

                  Since Mike addressed everything else, I'll just remark on the Audit Trail question.

                  The audit trail will be able to capture more changes than just polling FindChangedItems but, as you mentioned, does come with a performance hit.


                  Enabling Auditing effectively doubles the amount of writes that need to be performed on a database.  Parameters to consider would Disk I/O, Disk Space, and RAM.  If you are nearly maxing out your machine resources, Auditing might not be the best idea.  Otherwise, you could try it out and see how it affects performance.