# How not to change the msg when switching tabs?

**URL:** <https://discourse.nodered.org/t/how-not-to-change-the-msg-when-switching-tabs/64552>\
**Category:** General\
**Created:** [30 June 2022 16:15 UTC](https://discourse.nodered.org/t/how-not-to-change-the-msg-when-switching-tabs/64552 "2022-06-30T16:15:25Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![HuOliveiraWork](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/huoliveirawork/32/62521_2.png) [@HuOliveiraWork](https://discourse.nodered.org/u/HuOliveiraWork)\
**Post date:** [30 June 2022 16:15 UTC](https://discourse.nodered.org/t/how-not-to-change-the-msg-when-switching-tabs/64552/1 "2022-06-30T16:15:25Z")

</div>

Good afternoon,

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 changing the tab with ui control:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/e/ae6c631a065da74b261666a93d935ef79e87d892.png)

Here is my ui control config:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/a/8a1a5337b0ec5e6094d798460aabddf62a7ca263.png)  
And I want to access the msg down there:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/2/322af6b1948f7753848d624d01810e9f8fac6cd4.png)

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![HuOliveiraWork](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/huoliveirawork/32/62521_2.png) [@HuOliveiraWork](https://discourse.nodered.org/u/HuOliveiraWork)\
**Post date:** [13 July 2022 08:59 UTC](https://discourse.nodered.org/t/how-not-to-change-the-msg-when-switching-tabs/64552/3 "2022-07-13T08:59:55Z")

</div>

replying just to wake my question 🙂

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [13 July 2022 09:11 UTC](https://discourse.nodered.org/t/how-not-to-change-the-msg-when-switching-tabs/64552/4 "2022-07-13T09:11:48Z")

</div>

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](https://nodered.org/docs/user-guide/context))

---

<div class="post-metadata">

**Author:** ![HuOliveiraWork](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/huoliveirawork/32/62521_2.png) [@HuOliveiraWork](https://discourse.nodered.org/u/HuOliveiraWork)\
**Post date:** [13 July 2022 09:24 UTC](https://discourse.nodered.org/t/how-not-to-change-the-msg-when-switching-tabs/64552/5 "2022-07-13T09:24:20Z")

</div>

Thanks for the reply. I think it's really the use of global variables that can solve my problem, is there any way to debug global variables?

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [13 July 2022 09:31 UTC](https://discourse.nodered.org/t/how-not-to-change-the-msg-when-switching-tabs/64552/6 "2022-07-13T09:31:23Z")

</div>

If you look at the editor's side bar, there is a `Context Data` option with refresh buttons  
 ![Screen Shot 2022-07-13 at 5.30.11 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/1/21bf79dbc388cde9ad352092ac36809d44a0c079.png)

---

<div class="post-metadata">

**Author:** ![HuOliveiraWork](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/huoliveirawork/32/62521_2.png) [@HuOliveiraWork](https://discourse.nodered.org/u/HuOliveiraWork)\
**Post date:** [13 July 2022 09:37 UTC](https://discourse.nodered.org/t/how-not-to-change-the-msg-when-switching-tabs/64552/7 "2022-07-13T09:37:38Z")

</div>

That's what I needed. Thank you very much for the answers!

---

<div class="post-metadata">

**Author:** ![HuOliveiraWork](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/huoliveirawork/32/62521_2.png) [@HuOliveiraWork](https://discourse.nodered.org/u/HuOliveiraWork)\
**Post date:** [13 July 2022 10:02 UTC](https://discourse.nodered.org/t/how-not-to-change-the-msg-when-switching-tabs/64552/8 "2022-07-13T10:02:50Z")

</div>

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?

console.log(flow.server);

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [13 July 2022 10:16 UTC](https://discourse.nodered.org/t/how-not-to-change-the-msg-when-switching-tabs/64552/9 "2022-07-13T10:16:48Z")

</div>

> [@HuOliveiraWork](#):
>
> How do I get the value of the variables inside a template for example?

Inside what template? The `template` node? the `ui-template` node? Something else that you haven't explained?

---

<div class="post-metadata">

**Author:** ![HuOliveiraWork](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/huoliveirawork/32/62521_2.png) [@HuOliveiraWork](https://discourse.nodered.org/u/HuOliveiraWork)\
**Post date:** [13 July 2022 10:22 UTC](https://discourse.nodered.org/t/how-not-to-change-the-msg-when-switching-tabs/64552/10 "2022-07-13T10:22:10Z")

</div>

I'm sorry, I'm talking about ui-template.

I can show all my script, if it help:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/e/0e126008ed3a4d57b078de1f771c464f3f7ed5a0.png)

```auto
<script>
    
    var button = document.getElementsByClassName("winscp");
    
    button[0].onclick = function(){
        
        console.log(server);
        
        //var url = 'sftp://root:Estagio.2022@192.168.10.96';
        var url = `sftp://root:Estagio.2022@${flow.server}`;
        window.open(url, '_blank');
        
    };
    
    console.log(flow.server);

</script>

```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [13 July 2022 10:29 UTC](https://discourse.nodered.org/t/how-not-to-change-the-msg-when-switching-tabs/64552/11 "2022-07-13T10:29:58Z")

</div>

Hmmm, maybe @hotNipi can help with that.

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [13 July 2022 11:21 UTC](https://discourse.nodered.org/t/how-not-to-change-the-msg-when-switching-tabs/64552/12 "2022-07-13T11:21:07Z")

</div>

If I could understand the issue correctly... 🤔

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 ..

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [27 July 2022 11:21 UTC](https://discourse.nodered.org/t/how-not-to-change-the-msg-when-switching-tabs/64552/13 "2022-07-27T11:21:46Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
