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

AF SDK Reference

AFElements.Add Method (String)

  • Last UpdatedNov 18, 2025
  • 3 minute read
AFElements.Add Method (String)
This method is used to create a new AFElement without specifying a template.

Namespace:  OSIsoft.AF.Asset
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182

Syntax

public AFElement Add(
	string name
)
Public Function Add ( 
	name As String
) As AFElement

Dim instance As AFElements
Dim name As String
Dim returnValue As AFElement

returnValue = instance.Add(name)
public:
AFElement^ Add(
	String^ name
)
member Add : 
        name : string -> AFElement 

Parameters

name
Type: SystemString
The name for the new AFElement object. The name must be unique within the collection. If the name ends with an asterisk (*), then a unique name will be generated based on the supplied name. See the ValidateName(String, String) method for a description of what is valid when setting the name of the object.

Return Value

Type: AFElement
Returns the newly added AFElement object.

Remarks

The new AFElement is added to this collection using the default AFReferenceType - Parent-Child. Since an AFElementTemplate was not specified, properties that are normally defined by the template are defined by the element instead.

Top-level elements of the database can be created by using this method on the AFDatabase.Elements collection. To create a new child element of another element, use one of the Add methods of the element's AFElement.Elements collection. To add an existing child element of another element, use one of the Add Overload methods the element's AFElement.Elements collection.

When an element is first added to a AFModel, the element is not connected to any other elements. Use one of the AFConnections.Add Overload methods to create a connection between two elements within the model.

When a reference is added to or removed from an element, the parent element is checked out in the client, but it is not actually checked out in the server. This allows elements to be added to or removed from the collection from multiple applications and then checked in without requiring a checkout lock on the parent element in the server. If any other change is made to the parent element, a full server checkout is performed. Calling ApplyChanges will also require a full server checkout to be performed before saving to the server.

Important note Important
Only one reference between the AFDatabase and an AFElement is allowed and its AFReferenceStrength must be Strong.

Version Information

AFSDK


See Also

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