# Changing a Group Name Dynamically

**URL:** <https://discourse.nodered.org/t/changing-a-group-name-dynamically/100007>\
**Category:** Dashboard\
**Tags:** dashboard-2\
**Created:** [21 December 2025 23:19 UTC](https://discourse.nodered.org/t/changing-a-group-name-dynamically/100007 "2025-12-21T23:19:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![garynl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/garynl/32/95490_2.png) [@garynl](https://discourse.nodered.org/u/garynl)\
**Post date:** [21 December 2025 23:19 UTC](https://discourse.nodered.org/t/changing-a-group-name-dynamically/100007/1 "2025-12-21T23:19:38Z")

</div>

In dashboard 1 I used to use a template node containing some 'magic' code from this forum that allowed me to dynamically change the name of a group by passing msg.payload to this script:

```auto
<script>
(function($scope) {
$scope.oldGroupName = 'THP-X'; // initial group placeholder name

$scope.$watch('msg', function() {
    if ($scope.msg){
        $("p.nr-dashboard-cardtitle").each(function(){
            if($(this).text().trim() == $scope.oldGroupName.trim()){
                p = $(this);
                p.text($scope.msg.payload);
                 $scope.oldGroupName = $scope.msg.payload
            }
        })
    }
 });
})(scope);
</script>

```

This doesn't work in dashboard-2. Is there a piece of code available that does the same for dashboard-2? Or perhaps another way of doing it?

Gary

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [22 December 2025 02:50 UTC](https://discourse.nodered.org/t/changing-a-group-name-dynamically/100007/2 "2025-12-22T02:50:19Z")

</div>

> [@garynl](#):
>
> Or perhaps another way of doing it?

Do not show the group name.  
Add a text widget with blank label at the top of the group.

---

<div class="post-metadata">

**Author:** ![garynl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/garynl/32/95490_2.png) [@garynl](https://discourse.nodered.org/u/garynl)\
**Post date:** [22 December 2025 09:21 UTC](https://discourse.nodered.org/t/changing-a-group-name-dynamically/100007/3 "2025-12-22T09:21:25Z")

</div>

Works perfectly, funny how the best solutions are often the simplest!

---

<div class="post-metadata">

**Author:** ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)\
**Post date:** [22 December 2025 22:43 UTC](https://discourse.nodered.org/t/changing-a-group-name-dynamically/100007/4 "2025-12-22T22:43:47Z")

</div>

You could always do it the complicated way. This goes in a `ui-template` node with either page or group scope. 😁

```H
<script>
    export default {
        data() {
            // define variables available component-wide
            // (in <template> and component functions)
            return {
                groupTitle: 'Group Title' // Default Group Title for first search (whatever you
                                                        // called the group when setting it up)

            }
        },

        methods: {
            // Update the Group Title and Save
            updateHeader: function (newGroupName) {
                const header = Array.from(document.getElementsByClassName("v-card-title"))
                    .find(el => el.textContent === this.groupTitle)

                this.groupTitle = newGroupName
                header.textContent = this.groupTitle

            }

        },

        mounted() {
            this.$socket.on('msg-input:' + this.id, (msg) => {
                this.updateHeader(msg.payload)
            })
        },

        unmounted() {
            // code here when the component is removed from the Dashboard
            // i.e. when the user navigates away from the page
        }
    }
</script>

```

---

<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:** [5 January 2026 22:43 UTC](https://discourse.nodered.org/t/changing-a-group-name-dynamically/100007/5 "2026-01-05T22:43:48Z")

</div>

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