Writing to a tag and data type question

Hello,
I am trying to write to a memory tag called JobNumSelect, it is a string.

Inside of Extension Functions onDoubleClick
I have this code:

import system
system.tag.write("[PanelShop]JobNumSelect", “test”)

and it works like a charm
I put this:

import system
system.tag.write("[PanelShop]JobNumSelect", value)

and it does not work, it compiles the string does not appear as the value of the tag though. The value is from an nvarchar array.

I can get the value to come up if I right-click by using onPopupTrigger and its sample code, just inserting value instead of the string “Hello” in the code. It pops up a tooltip that says my job number which would be like 55555-1-1. So I know that value is returning this string but maybe I need to do something about datatype?

Unfortunately typecasting by using str(value) did not do the trick

Try the following

system.tag.write("[PanelShop]JobNumSelect",str(value))

Unfortunately typecasting by using str(value) did not do the trick

post all your code
caption your code in triple backquotes (above the tab key) this will format the code to be readable

is this in a power table? if so you would need to click on the correct row and correct column to get the value correct. Or you can add something like this to always choose the value at a certain column when you click anywhere on the row. Also, I don’t think you need to import system to run the tag write.

value = self.data.getValueAt(rowIndex, "Column Name")

If I just keep is simple with this inside of the onMousePress:

system.tag.write("[PanelShop]JobNumSelect", value)

it says

“AttributeError: ‘function’ object has no attribute ‘value’” - output console

I think I need to call it correctly, but if I use self.data.getValueAt(rowIndex, "Column Name")
instead its says:

“NameError: name ‘self’ is not defined”

I think it has something to do with what you said, and calling it correctly with the right syntax.

What component is this in?

Continuing the discussion from Writing to a tag and data type question:

It is a powertable

make sure the code is indented to be included in the function. This snapshot of code works for me

image

Thats great feedback thanks.
I fixed it by rebooting Ignition… Apparently it gets buggy when you feed non-string data types to a string memory variable.
str(value) was indeed the answer