Writing to a dataset client tag

Hello!

I am trying to write a vision component value to a dataset tag, but am having trouble getting it to work. I referenced the link below for support but I still get an error message.

I'm wondering if it isn't working because I am using a client tag? I pasted the error message I am getting and the code snippet below

Error message which references the first line of my code: AttributeError: 'com.inductiveautomation.ignition.common.model.valu' object has no attribute 'Value'

My code:

ds = system.tag.read("[client]calculatedData/PlantData").Value

system.tag.write('[client]calculatedData/PlantData',system.dataset.setValue(ds,4,1,event.source.value))

You're using uppercase V .Value. You need to use lowercase V .value. Python, like most programming languages, is case sensitive. Most things in Ignition, even in Python, follow the Java convention of lowerCamelCase, rather than e.g. snake_case, kebab-case, or UpperCamelCase.

Thank you, didn't spot that. I adjusted but got the following error instead:

TypeError: 'com.inductiveautomation.ignition.common.model.values.BasicQualifiedValue' object is unsubscriptable

Post the exact script you're using, ideally inside a preformatted text block (use this icon in the formatting toolbar image)

I just realized the problem -

On my write line I was using '' instead of ""

The syntax of these read/write functions confuse me. I had copied the code from a snippet where I had used a list format that used '' within the brackets, if that makes sense? Anyway just two syntax issues in the end, thanks for your help. I posted the working code below in case anyone else is running into issues with this syntax.

ds = system.tag.read("[client]calculatedData/PlantData").value

system.tag.write("[client]calculatedData/PlantData",system.dataset.setValue(ds,4,1,event.source.value))

The TL;DR is that system.tag.read and system.tag.write were technically deprecated in favor of system.tag.read(Blocking|Async) and system.tag.write(Blocking|Async); the new functions have more clear semantics and accept a list of paths/values, which helps to reduce a common performance issue for new users. The tradeoff is they're a bit more confusing at first glance - they accept a list of values, and therefore return a list of values - so you might see e.g. system.tag.readBlocking(["tagA"])[0].value, which has an awful lot of square brackets that don't add a whole lot of clarity.

In spite of their "deprecation", note that we're absolutely not going to remove the existing read or write functions, for the sake of backwards compatibility. For writing a single tag, there's not really any reason to switch.