Does anyone know how I can change tabs without changing my msg variable, I needed to access some data that I had in the msg inside a new tab. But allways reset the variable properties.
I'm a little unclear about what you are asking. msg's in a flow go from node to node across the wires they are attached to. If you want the data in a msg to be used in another flow, you have to store it some where. That could be in a database, a flow/global variable or even in a mqtt msg.
Not understanding what your flows are doing, I'd suggest trying usig a flow variable unless you need the data on a different editor page in which case you would use a global (you can read about context variables here: Working with context : Node-RED)
I apologize but I was left with another doubt that I think fits with the topic. How do I get the value of the variables inside a template for example? Shouldn't this log work?
Your button is not implemented in the way the Node-RED server side and dashboard would like it to be.
Long story to tell ...
But thankfully there is built in help for each node. The ui_template node has very good help page.
It shows examples how to create front-end widget which can receive messages from back-end side and how to use that data. Of course, any case is a bit different but you'll get basics done quick and correct.
Then if you still have problems, let's deal with specific questions ..