# PackedHistoricalTagValue uses Deprecated TagPath

**URL:** <https://forum.inductiveautomation.com/t/packedhistoricaltagvalue-uses-deprecated-tagpath/96364>\
**Category:** Module Development\
**Created:** [September 24, 2024, 1:38pm UTC](https://forum.inductiveautomation.com/t/packedhistoricaltagvalue-uses-deprecated-tagpath/96364 "2024-09-24T13:38:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cole\_Townsend](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cole_townsend/32/53149_2.png) [@Cole\_Townsend](https://forum.inductiveautomation.com/u/Cole_Townsend)\
**Post date:** [September 24, 2024, 1:38pm UTC](https://forum.inductiveautomation.com/t/packedhistoricaltagvalue-uses-deprecated-tagpath/96364/1 "2024-09-24T13:38:57Z")

</div>

The docs for [PackedHistoricalTagValue](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.42/com/inductiveautomation/ignition/gateway/history/PackedHistoricalTagValue.html) show a constructor that uses a [TagPath](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.42/com/inductiveautomation/ignition/common/sqltags/model/TagPath.html) Object.

I'm trying to store data in the tag historian tables using 'virtual' tags to use the pre-existing Power Chart component to display data easily along with other tags data.

Does the following show the correct way to instantiate a TagPath object? I have the following function, and it seems like these tags are making their way to the memory buffer without being quarantined, but I do not see any rows being added to my historian tables.

```python
private static HistoryManager history;

private static String tagProviderName = "Completions";

private static void storeTagValue(String jobId, String apiNum, String key, Object value, Date timestamp, DataTypeClass dataType) throws Exception {
        TagPath tagPath = TagPathParser.parse(String.format("[%s]/%s/%s", tagProviderName, jobId, apiNum, key));
        PackedHistoricalTagValue tagValue = new PackedHistoricalTagValue(
                tagPath,
                dataType,
                InterpolationMode.Discrete,
                TimestampSource.Value,
                value,
                DataQuality.GOOD_DATA,
                timestamp
        );
        history.storeHistory("mocazuresql01_SCADA", tagValue);
    }

```

Am I missing something obvious with this Class?

---

<div class="post-metadata">

**Author:** ![Cole\_Townsend](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cole_townsend/32/53149_2.png) [@Cole\_Townsend](https://forum.inductiveautomation.com/u/Cole_Townsend)\
**Post date:** [September 24, 2024, 7:48pm UTC](https://forum.inductiveautomation.com/t/packedhistoricaltagvalue-uses-deprecated-tagpath/96364/2 "2024-09-24T19:48:50Z")

</div>

I haven't quite figured it out yet, but I've made a bit of progress. I followed the advice from this old forum post and wrapped my historical data in a BasicScanClassHistorySet, and that managed to start storing data points, but it's not setting up the entries in sqlth\_te, sqlth\_scinfo, sqlth\_sce, and sqlth\_drv correctly.

Specifically, it is populating the entries with null ID's, making the historical data impossible to reference.

sqlth\_te:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/2/9243025baee0efe2507c7dee98901745172fea16.png)

sqlth\_scinfo:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/c/3c33f9446c1edddb0f4d0974b4377e907b89e9e9.png)

sqlth\_sce:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/0/400f6f4a4d33e284cd148c47c255548a8f3b1c01.png)

sqlth\_partitions:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/c/bce1cf52592f6723b242ee03731ef17d745d2b3d.png)

sqlth\_drv:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/d/2d9953d93a9f9564e67321e8c65177d0b2013d5b.png)

sqlt\_data:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/d/9d6da9c3fe3c66e5a8fe0eac2873a4cac9d58782.png)

Here is the current code:

```python
private static void storeTagValue(String jobId, String apiNum, String key, Object value, Date timestamp, DataTypeClass dataType) throws Exception {
        if (value != null) {
            BasicScanclassHistorySet bshs = new BasicScanclassHistorySet(tagProviderName, "googlePubSub", 0);
            TagPath tagPath = TagPathParser.parse(String.format("completions/%s/%s/%s", jobId, apiNum, key));
            PackedHistoricalTagValue tagValue = new PackedHistoricalTagValue(
                    tagPath,
                    dataType,
                    InterpolationMode.Discrete,
                    TimestampSource.Value,
                    value,
                    DataQuality.GOOD_DATA,
                    timestamp
            );
            bshs.add(tagValue);
            if(history.getStatusInfo("mocazuresql01_SCADA").get(0).isAvailable()) {
                history.storeHistory("mocazuresql01_SCADA", bshs);
            } else {
                throw new Exception("Store and Forward is not available");
            }
        }
    }

```

---

<div class="post-metadata">

**Author:** ![Cole\_Townsend](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cole_townsend/32/53149_2.png) [@Cole\_Townsend](https://forum.inductiveautomation.com/u/Cole_Townsend)\
**Post date:** [September 25, 2024, 1:53pm UTC](https://forum.inductiveautomation.com/t/packedhistoricaltagvalue-uses-deprecated-tagpath/96364/3 "2024-09-25T13:53:08Z")

</div>

@pturmel @Kevin.Herron @paul-griffith Sorry to ping you guys, but do any of you have any experience with the Ignition SDK and the Tag Historian? The JavaDocs aren't doing me many favors regarding my issues.  
You guys are my go-to with the hard questions... sorry.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 25, 2024, 2:11pm UTC](https://forum.inductiveautomation.com/t/packedhistoricaltagvalue-uses-deprecated-tagpath/96364/4 "2024-09-25T14:11:06Z")

</div>

No need to ever ping me. I read everything here, and didn't have an answer for you. (I do have some experience with History sinks, but they didn't work the way I wanted. I'm proceeding with a design based on a TagActor.)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 25, 2024, 3:08pm UTC](https://forum.inductiveautomation.com/t/packedhistoricaltagvalue-uses-deprecated-tagpath/96364/5 "2024-09-25T15:08:16Z")

</div>

The `storeTagHistory` function creates a `BasicTagGroupHistorySet` (with an apparently special tag group name):

```java
BasicTagGroupHistorySet data = new BasicTagGroupHistorySet(tProv, "_existing_", 0);

```

Then adds `PackedHistoricalTagValues` to it:

```java
com.inductiveautomation.ignition.common.sqltags.model.TagPath oldStyleTagPath =
    com.inductiveautomation.ignition.common.sqltags.parser.TagPathParser.parse(tProv, paths[i]);
data.add(new PackedHistoricalTagValue(oldStyleTagPath, getDataType(v),
    InterpolationMode.Analog_Compressed, TimestampSource.Value, v, q, ts));

```

Then you pass `data` to the `StoreAndForwardManager` you got from the `GatewayContext`:

```java
getStoreAndForwardManager().storeData(hProv, data);

```

Disclaimer: All I'm doing is reading the code for an existing solution; I can guarantee you two things:

1. I'm not an expert in this area, so I can't help you if you need to deviate from this significantly.
2. There's going to be a new, preferred API to do this in 8.3. The existing API will (probably) continue to work, for backwards compatibility, but some amount of migration may be necessary.
