Use derived tag to read/write to database value

I'm trying to set up a Derived Tag and use the "Read Expression" (i.e., getter) and "Write Expression (i.e. setter) to read/write to a database value.

I'm having trouble with the Write Expression.
image

It calls a runScript() expression function, which calls db.setDeviceField()
image

But every time I try to write to the derived tag, I get "Bad_ReferenceNotFound"
image

I've already tried changing the Gateway Scripting Project but nothing seems to resolve the reference not found error. What am I missing?

That is not how derived tags are meant to be used.
You should be doing an out-of-band side effect via a tag event script.

This is a bad idea. We used to have a concept of a "database" tag provider and intentionally removed it from the product. Synchronization is an endless source of headaches.

I've got a solution working for keeping reads synchronized, but it would be nice to be able to read and write from the same tag so I can treat it like any other OPC tag in Vision/Perspective.

Do you have any suggestions?