Help with system.tag.addTag

Does anyone have an example adding a tag with history using system.tag.addTag?

Yea, it would look something like this:

system.tag.addTag(parentPath="", name=“Tag2”, tagType=“MEMORY”,
dataType=“Int2”, value=25, attributes={“HistoryEnabled”:“TRUE”, “PrimaryHistoryProvider”:“DB”})

All of the history settings would go in the "attributes section of the parmeters. Also below is a link to a scripting functions manual, and if you go to system.tag.addTag, in the parameters section next to attributes, there will be a link for Tag Attributes, that will provide a list of all the possible attributes for a tag. Just note that the attributes for the alarms should go into the alarmConfig parameter.

files.inductiveautomation.com/mo … index.html

Got it. Thanks

system.tag.addTag(parentPath="Folder", name="Test", tagType="MEMORY", dataType="Boolean", value=0, attributes={"HistoryEnabled":"TRUE", "PrimaryHistoryProvider":"DB", "HistoricalScanclass":"<Evaluate On Change>","HistoricalDeadband":"1.0", "InterpolationMode":"2"})

An important note: do NOT specify the Historical Scan class as “” - it should be stored as an empty string to achieve that:

system.tag.addTag(parentPath="Folder", name="Test", tagType="MEMORY", dataType="Boolean", value=0, attributes={"HistoryEnabled":"TRUE", "PrimaryHistoryProvider":"DB", "HistoricalScanclass":"", "HistoricalDeadband":"1.0",  "InterpolationMode":"2"})