Writing to memory tag from a custom property with a binding

Hi,

I am trying to write to a Memory tag from a custom property that is updated by its binding when its updated my script looks like this

def valueChanged(self, previousValue, currentValue, origin, missedEvents):
tagPath = "[default]Path/To/Your/MemoryTag"value = "self.custom.Value"
system.tag.writeAsync([tagPath], [value])

I know I’ve done something wrong but I can’t find it

Is this supposed to have quotes around it? If you’re writing the new value of the custom property to the tag (I can’t tell if this is what you are doing), you’ll want to use currentValue.value. If you’re still stuck, what isn’t working – is it writing the wrong value to the tag, or not writing at all? Have you confirmed the script is firing in the first place?

1 Like

Tip: Wiki - how to post code on this forum.

2 Likes

Thanks for the reply, I am unsure if the quotes are needed or not, but yes I am trying to write the new value (true/false) of the custom property to the memory tag.

I have made your suggested changes so my code now looks like this -

def valueChanged(self, previousValue, currentValue, origin, missedEvents):
tagPath = "[default]Path/To/Your/MemoryTag"value = currentValue.value
system.tag.writeAsync([tagPath], [value])

However I am still having the same problem, it seems the tag is not being written to at all.

Is your actual code as shown below? (Note proper indentation and four lines rather than your three.)

def valueChanged(self, previousValue, currentValue, origin, missedEvents):
    tagPath = "[default]Path/To/Your/MemoryTag"
    value = currentValue.value
    system.tag.writeAsync([tagPath], [value])

Yes, sorry I missed a carriage return where you have indicated

Thanks again for this, seems it was this plus the issue of the section of the tag list I was working in had been made read only by the admin