Skip to main content
Version: 8.3

system.historian.storeMetadata

This function is used in Python Scripting.

Description​

Store a list of metadata to the specified historian. This function applies to the Core Historian and Internal Historian only.

Changed in 8.3.5
Metadata can be provided as individual parameter lists or as objects created with system.historian.types.metadataPoint.

When provided as individual parameter lists, ensure all parameters are 1:1, meaning all provided lists must be of the same length. If a particular annotation doesn't need a parameter, that element can be None in the list.

Client Permission Restrictions​

This scripting function has no Client Permission restrictions.

Syntax #1​

system.historian.storeMetadata(paths, timestamps, properties)

Parameters​

TypeParameterDescription
ListpathsA list of historical paths. See Path Syntax for more information on recommended syntax.
ListtimestampsA list of timestamps.
DictionarypropertiesA dictionary of desired properties to be stored as historical metadata, entered as defined key-value pairs corresponding to any relevant tag properties.

Returns​

List - A list of QualityCode objects. The quality code will indicate success or failure.

Scope​

Gateway, Vision Client, Perspective Session

Syntax #2​

system.historian.storeMetadata(metadata)

Parameters​

TypeParameterDescription
ListmetadataA list of metadata point objects created with system.historian.types.metadataPoint.

Returns​

List - A list of QualityCode objects. The quality code will indicate success or failure.

Scope​

Gateway, Vision Client, Perspective Session

Code Examples​

Code Snippet 1: Syntax #1
# Store a single property to a specified historical tag path and log an info level formatted message.

paths = ["histprov:Historian:/sys:gw1:/prov:default:/tag:remote_200"]
curr = system.date.now()
timestamps = [curr]
properties = { "tooltip": "changing with perspective"}

results = system.historian.storeMetadata(paths, timestamps, properties)

system.util.getLogger('HistorianTest: storeMetadata').info(str(results))
Code Snippet 2: Syntax #1
# Store a list of properties to a specified historical tag path.

qualityCodes = system.historian.storeMetadata(
paths=["histprov:CoreHistorian:/sys:gateway:/prov:default:/tag:Folder/MyTag"],
timestamps=[system.date.now()],
properties={
"engUnit": "degF",
"engLow": 0.0,
"engHigh": 500.0,
"documentation": "Main reactor temperature sensor",
"calibrationDate": "2024-01-15"
}
)
Code Snippet 1: Syntax #2
# Create metadata using the types API and store it

source = "histprov:CoreHistorian:/sys:gateway:/prov:default:/tag:Folder/MyTag"
properties = {"tooltip":"metadata text"}
timestamp = system.date.now()
metaDataPoints = [system.historian.types.metadataPoint(source, properties, timestamp)]

system.historian.storeMetadata([metadata])