Store value in persistent/global variable

Is there a way to store a value in a variable that would persist while a device is on? I have a rule that each time it runs, I’d like to get and set a persistent variable. I’ve tried creating a custom item, but when I try to reference it, I get “The method or field prevVolume is undefined;” Is there another way to accomplish this?

We needs lots more details.

Rule written how? What language? Created the Item how? How are you trying to reference the Item?