GetValue Method not retrieving new Attribute Value

Discussion created by fraser on Dec 3, 2009
Latest reply on Dec 8, 2009 by spilon

I am setting an AF Attribute, with a PI tag data reference “ALERT_PI” to equal the value of another AF Attribute “ALERT”. The problem that I am having is with the GetValue method, which only seems to fetch the attribute value when I initially set the object. It then holds this value in memory and uses it every subsequent time I use the GetValue method. If I change the value of the “ALERT” attribute, from the system explorer, and run the code again, the “ALERT_PI” attribute is set to the initial “ALERT” attribute value, not the new “ALERT” attribute value.


The code is:

Dim myPISystems As New PISystems
Dim myPISystem As PISystem = myPISystems("bkkhqntsp04")
Dim myDB As AFDatabase = myPISystem.Databases("TEST_AF_SERVER")

For Each myElement As AFElement In myDB.Elements
    If myElement.Template.Name = "BC_01" Then
        Dim Alert As AFAttribute = myElement.Attributes("ALERT")
        Dim Alert_PI As AFAttribute = myElement.Attributes("ALERT_PI")
        Dim attrValue As AFValue = Alert.GetValue

        attrValue.Timestamp = Time.AFTime.Now
        Alert_PI.DataReference.ConfigString += ";ReadOnly=False"
        Alert_PI.DataReference.SetValue(Nothing, attrValue)
    End If

Thank you in advance.