Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AF SDK Reference

PIPoint.SaveAttributes Method (String[])

  • Last UpdatedJan 12, 2026
  • 4 minute read
PIPoint.SaveAttributes Method (String[])
Save the PIPoint attribute values in the cache to the server.

Namespace:  OSIsoft.AF.PI
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.2.0.7

Syntax

public AFErrors<string> SaveAttributes(
	params string[] names
)
Public Function SaveAttributes ( 
	ParamArray names As String()
) As AFErrors(Of String)

Dim instance As PIPoint
Dim names As String()
Dim returnValue As AFErrors(Of String)

returnValue = instance.SaveAttributes(names)
public:
AFErrors<String^>^ SaveAttributes(
	... array<String^>^ names
)
member SaveAttributes : 
        names : string[] -> AFErrors<string> 

Parameters

names
Type: SystemString
The list of PIPoint attribute names to be saved. The PICommonPointAttributes class contains some of the common PIPoint attribute names. If or an empty list, then all loaded attribute values will be saved.

Return Value

Type: AFErrorsString
Returns an AFErrorsTKey object which contains any errors that occurred during the save. If the error is related to PIServer connection then PIServerErrors key is the PIServer name, otherwise Errors key is the PIPoint name. If no errors occur, then be returned.

Remarks

The PIPoint attribute values for the specified list of are saved from the client's cache to the server. The SetAttribute(String, Object) method should be used to modify the PIPoint attribute value before saving. When the PIPoint attribute values are no longer needed, the UnloadAttributes(String) method or the UnloadAllAttributes(String) method can be called to remove the attribute values from the cache and free memory.

Examples

// This example demonstrates how to create an attribute for an
// element and retrieve and set PIPoint attributes.

// Get the Database
PISystems myPISystems = new PISystems();
PISystem myPISystem = myPISystems.DefaultPISystem;
AFDatabase myDB = myPISystem.Databases.DefaultDatabase;

// Create an Element Template
AFElementTemplate myElemTemplate = myDB.ElementTemplates.Add("MyElementTemplate");
AFAttributeTemplate myAttrTemplate = myElemTemplate.AttributeTemplates.Add("Attr#1");
myAttrTemplate.DataReferencePlugIn = AFDataReference.GetPIPointDataReference(myPISystem);
myAttrTemplate.ConfigString = @"\\%Server%\%Element%;pointtype=Float64";

// Create an Element from the Element Template
AFElement myElement = myDB.Elements.Add("MyElement", myElemTemplate);

// Create the PIPoint for the Attribute
AFAttribute myAttribute = myElement.Attributes["Attr#1"];
myAttribute.DataReference.CreateConfig();

// Find all PIPoint Attributes and Display their values
object drAttrValue;
myAttribute.PIPoint.LoadAttributes();
IEnumerable<string> list = myAttribute.PIPoint.FindAttributeNames(null);
Console.WriteLine("Found PIPoint Attributes: nameFilter='<null>'");
foreach (string item in list)
{
    drAttrValue = myAttribute.PIPoint.GetAttribute(item);
    Console.WriteLine("  {0} = '{1}'", item, drAttrValue);
}
Console.WriteLine();

// Find PIPoint Attributes matching 'Ex*' and display their values
list = myAttribute.PIPoint.FindAttributeNames("Ex*");
Console.WriteLine("Found PIPoint Attributes: nameFilter='Ex*'");
int cnt = 0;
foreach (string item in list)
{
    cnt++;
    drAttrValue = myAttribute.PIPoint.GetAttribute(item);
    Console.WriteLine("  {0} = '{1}'", item, drAttrValue);
}
Console.WriteLine();

// Unload all PIPoint Attributes
myAttribute.PIPoint.UnloadAllAttributes();

// Load specific PIPoint Attributes and display their values
myAttribute.PIPoint.LoadAttributes(PICommonPointAttributes.PointType,
    PICommonPointAttributes.PointID,
    PICommonPointAttributes.Descriptor,
    PICommonPointAttributes.ExtendedDescriptor,
    PICommonPointAttributes.CreationDate);
drAttrValue = myAttribute.PIPoint.GetAttribute(PICommonPointAttributes.PointType);
Console.WriteLine("PIPoint Attribute '{0}' = '{1}'.", PICommonPointAttributes.PointType, drAttrValue);
drAttrValue = myAttribute.PIPoint.GetAttribute(PICommonPointAttributes.PointID);
Console.WriteLine("PIPoint Attribute '{0}' = '{1}'.", PICommonPointAttributes.PointID, drAttrValue);
drAttrValue = myAttribute.PIPoint.GetAttribute(PICommonPointAttributes.Descriptor);
Console.WriteLine("PIPoint Attribute '{0}' = '{1}'.", PICommonPointAttributes.Descriptor, drAttrValue);
drAttrValue = myAttribute.PIPoint.GetAttribute(PICommonPointAttributes.ExtendedDescriptor);
Console.WriteLine("PIPoint Attribute '{0}' = '{1}'.", PICommonPointAttributes.ExtendedDescriptor, drAttrValue);
drAttrValue = myAttribute.PIPoint.GetAttribute(PICommonPointAttributes.CreationDate);
Console.WriteLine("PIPoint Attribute '{0}' = '{1}'.", PICommonPointAttributes.CreationDate, drAttrValue);
Console.WriteLine();

// Set PIPoint Attribute value
string newAttrValue = "New Value: " + DateTime.Now.ToShortTimeString();
myAttribute.PIPoint.SetAttribute(PICommonPointAttributes.Descriptor, newAttrValue);
myAttribute.PIPoint.SetAttribute(PICommonPointAttributes.ExtendedDescriptor, newAttrValue);
AFErrors<string> errors = myAttribute.PIPoint.SaveAttributes(PICommonPointAttributes.Descriptor,
    PICommonPointAttributes.ExtendedDescriptor);
if (errors != null && errors.HasErrors)
{
    Console.WriteLine("Errors calling PIPoint.SaveAttributes:");
    foreach (var item in errors.Errors)
    {
        Console.WriteLine("  {0}: {1}", item.Key, item.Value);
    }
}

Version Information

AFSDK


See Also

In This Topic
TitleResults for “How to create a CRG?”Also Available in