I haven't used any of the object data types, but I have tried creating formula attributes where one of the referenced attributes had a string value type. This of course didn't work very well. It could seem like the formula data reference is very strict on which attribute value types you actually can use.
Maybe someone else knows more about this?
Pretty sure you can't use the navigational path syntax to jump to an AFElement that is set as the value of an AF Attribute.
@Michael, @Asle: Formula Data Reference allows showing the value of an element's attribute located elsewhere in the hierarchy (or another attribute of the current element). Although, this data reference does not support any string output. For this purpose, I have created the Alias Data Reference as an example for the PI Application Development Course that does what you want. It supports any type of value (including string). You can make use of the relative and absolute path method to an attribute.
For example, you might want to "expose" one information from 2 levels in the hierarchy regarding your current attribute, you can use the following syntax for the configstring property: ..\..\AnotherElement|MyAttribute You can use an absolute path like this: \\MyServer\MyDB\Element1\Line1\Part1|MyAttribute This data reference supports both GetValue and GetValues methods.
You can find an excerpt of the project here! The code and information are provided as is without warranty of any kind.
Let me know if that helped.
For this purpose, I have created the Alias Data Reference as an example for the PI Application Development Course that does what you want. It supports any type of value (including string). You can make use of the relative and absolute path method to an attribute.
Mathieu, I can definitely use this so this goes in my toolbox. Bit too late now, but we had a project before the summer where we had transformers using the terms HV and MV, which needed to be visible to the ProcessBook users as the ERD values. But the tags followed the AF template, which had the possibility of storing 400 kV, 220 kV and 110 kV voltage level tags. For some transformers the HV level would be 400 and the MV would be 110, for others it could be HV=220 and MV=110, and here we used formula attributes to create these "aliases" with a simple badval check also.
But as mentioned, this only worked for number value types.
I have been trying: A=..\.|ElementRefTest|RollupTest; but this does not seem to work.
So I am wondering what the Formula data reference syntax is to achieve this. I looked in the AF documents but could not find it, if I have missed it please someone point me in the right direction.
@Mike: This won't work because that is an AF Path that expects the attribute "ElementRefTest" Attribute to have a child Attribute "RollupTest", which is not what you want. As I already said you cannot do what you want to do to my knowledge, you will need a different approach other than having the Value Type of the Attribute being an Element.
Thanks all for the replies.
I got around the scenario by using the PI Point data reference and copying in the tags I wanted from the element valued attribute rather than using a formula on a template. It would have been more ideal to be able to use the formula to do this as then if the element in the attribute needed to change it would be simple and I would not need to trace through and change multiple PI Point data references.
In case anyone was wondering the scenario was that I had an element representing a test separator in an attribute on a well, so that if the well was on test, the formula could go and check what the flow rates were for the current test. In the asset I am modelling its feasible that the test sep could be changed and so I wanted a simple way to manage this scenario.
@Mathieu thanks for the code it looks like it might go part way to achieving what I want to do and I will definitely examine it further.