5 Replies Latest reply on May 2, 2016 7:32 PM by wling1

    AF SDK C# Code to delete child elements through iteration?



      I am having difficulty getting my code to work. What I am attempting to do is delete all of the child elements of a specific element. My code seems to run without error but nothing actually happens in AF. Here is my code:AFElement deviceList = afdb.Elements["Device List"];        

      PISystem afServer = new PISystems()["PI-AF"];
      AFDatabase afdb = afServer.Databases["MY-Database"];
      AFElement deviceList = afdb.Elements["Device List"];                //Defines AF Element 'Device List' to which child elements are to be deleted from
          var delAFElements = AFElement.FindElements(afdb, deviceList, "*",AFSearchField.Name, true,AFSortField.Name,AFSortOrder.Ascending,100);
          foreach (var toDelete in delAFElements)


      It seems to find the child elements I want to delete but does not actually delete them, so I am unsure if I am missing something. When I replace "deviceList" in my FindElements method with "null" it will delete my top level elements fine, but that is not what I am looking for. Any help is much appreciated!