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

AF SDK Reference

PIServer.TryConvertToServerID Method

  • Last UpdatedNov 18, 2025
  • 2 minute read
PIServer.TryConvertToServerID Method
Convert a string key to a PIServer ID.

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

Syntax

public static bool TryConvertToServerID(
	string key,
	out Guid serverId
)
Public Shared Function TryConvertToServerID ( 
	key As String,
	<OutAttribute> ByRef serverId As Guid
) As Boolean

Dim key As String
Dim serverId As Guid
Dim returnValue As Boolean

returnValue = PIServer.TryConvertToServerID(key, 
	serverId)
public:
static bool TryConvertToServerID(
	String^ key, 
	[OutAttribute] Guid% serverId
)
static member TryConvertToServerID : 
        key : string * 
        serverId : Guid byref -> bool 

Parameters

key
Type: SystemString
The server key to be converted to a PIServer ID.
serverId
Type: SystemGuid
The converted PIServer ID.

Return Value

Type: Boolean
Returns if the key was successfully converted to a PIServer ID. Returns if the key was not in a Guid or Int32 format and the returned serverId will be a newly generated ID.

Remarks

This is a helper method to convert a string key in Guid or Int32 format to a PIServer ID. Older versions of the PIServer that have been upgraded from a PI 2 server to a PI 3 server will have an ID in a 5 digit number format.

Version Information

AFSDK


See Also

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