AnsweredAssumed Answered

PI-AF: How to import xml to PI-AF server using PIImportMode.PresrveUniqueIDs

Question asked by Noga on Jan 8, 2019
Latest reply on Jan 9, 2019 by David Hearn

I am trying to grammatically import to a PI-AF server all the AFContact objects list, from an xml I exported from another PI-AF server.

I have no way to connect to the PI-AF server from which I exported the xml.

I also wish to preserve the objects original GUID, and therefor I want to use the new PIAFSDK PIImportMode.PresrveUniqueIDs import flag (from SDK v-2.10 2018).


but I am not sure of the way to do that.


I wrote the following .net code, but still I am missing the right way to call the PISystem.ImportXml method.

My partial code:



doc = new XmlDocument();

XmlNodeList contactList = doc.GetElementsByTagName("AFContact");


var contacts = AFContact.FindContacts(sys, "*", AFSearchField.Name, AFSortField.Name, AFSortOrder.Ascending, 1000);


sys.ImportXml(contacts, PIImportMode.AllowCreate | PIImportMode.AllowUpdate | PIImportMode.PreserveUniqueIDs | PIImportMode.AutoCheckIn, ???




As I mentioned, the correct call to the SYS.ImportXml method and how I can convert the XmlNodeList to the last faction argument is not clear to me.

I will be greatefull for any suggestion.