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

AF SDK Reference

AFData.ReplaceValuesAsync Method (AFTimeRange, AFValues, CancellationToken)

AFData.ReplaceValuesAsync Method (AFTimeRange, AFValues, CancellationToken)

  • Last UpdatedNov 18, 2025
  • 4 minute read
AFData.ReplaceValuesAsync Method (AFTimeRange, AFValues, CancellationToken)
This method removes existing data within the specified AFTimeRange and inserts the specified values on the target system using the configured data reference.

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

Syntax

public Task<AFErrors<AFValue>> ReplaceValuesAsync(
	AFTimeRange timeRange,
	AFValues values,
	CancellationToken cancellationToken = default
)
Public Function ReplaceValuesAsync ( 
	timeRange As AFTimeRange,
	values As AFValues,
	Optional cancellationToken As CancellationToken = Nothing
) As Task(Of AFErrors(Of AFValue))

Dim instance As AFData
Dim timeRange As AFTimeRange
Dim values As AFValues
Dim cancellationToken As CancellationToken
Dim returnValue As Task(Of AFErrors(Of AFValue))

returnValue = instance.ReplaceValuesAsync(timeRange, 
	values, cancellationToken)
public:
Task<AFErrors<AFValue^>^>^ ReplaceValuesAsync(
	AFTimeRange timeRange, 
	AFValues^ values, 
	CancellationToken cancellationToken = CancellationToken()
)
member ReplaceValuesAsync : 
        timeRange : AFTimeRange * 
        values : AFValues * 
        ?cancellationToken : CancellationToken 
(* Defaults:
        let _cancellationToken = defaultArg cancellationToken new CancellationToken()
*)
-> Task<AFErrors<AFValue>> 

Parameters

timeRange
Type: OSIsoft.AF.TimeAFTimeRange
The bounding time range for replacement of the existing values.
values
Type: OSIsoft.AF.AssetAFValues
The replacement values to be written on the target system. If an empty AFValues then existing data within the specified AFTimeRange will be deleted. The timestamp of AFValue in values must be within the specified AFTimeRange.
cancellationToken (Optional)
Type: System.ThreadingCancellationToken
A cancellation token used to abort processing before completion. Passing the default CancellationToken.None will run to completion or until the PIConnectionInfo.OperationTimeOut period elapses.

Return Value

Type: TaskAFErrorsAFValue
Returns a task whose result is if there are no errors. Otherwise the result is an AFErrorsTKey instance containing error information.

Exceptions

ExceptionCondition
AggregateException Asynchronous methods throw AggregateException on failure which will contain one or more exceptions containing the failure.
InvalidOperationException The Attribute does not have a data reference configured.
NotSupportedException The data reference does not support this method.

Remarks

This method requires that the attributes being written, if configured with a data reference, must support the ReplaceValues method. This is indicated by having the ReplaceRange flag set in the SupportedDataMethods property. The PI Point Data Reference supports ReplaceValues for simply configured PI Points.

If AFBufferOption is set to Buffer, this method requires that the attribute has a configured data reference which supports buffering. This is indicated by having the Buffering flag set in the SupportedDataMethods property. The PI Point Data Reference supports buffering.

Note Notes to Callers
This method, property, or class is not available in the legacy .NET 3.5 version of the SDK.

Security note Security Note
You must have WriteData security rights to write a data value.

Important note Important
This method is not supported for attributes that do not have a data reference.

Note Notes to Callers
This call might use a background task to complete some of its work. See the Threading Overview for some matters to consider when execution transitions to another thread.

Version Information

AFSDK

Supported in: 3.1.1, 3.1.0, 3.0.2, 3.0.1, 3.0.0, 2.10.11, 2.10.5, 2.10.0, 2.10, 2.9.5, 2.9, 2.8.5, 2.8

See Also

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