I'm writing an application (PI AF SDK) where a user should be able to store the exported xml for an element template, keep it for later, and then re-import it into the AF Server as a backup.
I would like to retain elements derived from the template, and their values, just like you do in PI System Explorer if you change template and the attribute templates also exist in the destination template. The attributes must keep their values, I don't want them reset to whatever is specified in the template.
|Original element template|
|Modified element template|
I've tried to simply import the XML into the same element template, but this only adds content which was missing - it doesn't remove attribute templates from AF. See the two tables. If I import the XML of the original template into the modified template I end up with this:
This is not what I want. I want to go back to the state of the original template. I figure I need to keep editing the template in question, in order to keep derived elements and not lose attribute values, so I tried clearing the collection of attribute templates before importing. Now the attribute template collection is the same as in the original template, but I didn't retain the attribute values of the derived elements. Attribute2 had a manually entered string value in one of my elements, and this was reset to the value specified in the template. So I'm a bit stuck here now.