Warning about the %Server% replacement variable in AF

Blog Post created by dfsoll on Nov 10, 2017

In AF, when you create a new PI Point AF Attribute template in an AF Element template, you will notice that the default setting for this attribute is: \\%Server%\%Element%.%Attribute%".  Care should be taken when using the %Server% replacement parameter as it may resolve in a way that you might not expect.


The %Server% replacement parameter will use the default PI server based on the AF client that you are using.  This means that when a user adds an element using the PI System Explorer from their own workstation, the %Server% will be substituted with that user's default PI server.  If your organization has more than one PI server, this could be a problem.


A better solution might be to have an attribute named "PI Server" and utilize that attribute in the configuration string.  If the "PI Server" attribute is defined in an AF Element template that is used as the base template for all other AF Element templates, you could define it as a "String Builder" type with "'..\|PI Server'" as its configuration string.  This will cause the "PI Server" attribute to always be available in every element as well as inherit the "PI Server" value from its parent.  You only need to set the "PI Server" value in the root node of your AF Element hierarchy.