# Dynamic label update on button press

**URL:** <https://forum.inductiveautomation.com/t/dynamic-label-update-on-button-press/103797>\
**Category:** Ignition\
**Tags:** scripting, perspective\
**Created:** [March 17, 2025, 6:01pm UTC](https://forum.inductiveautomation.com/t/dynamic-label-update-on-button-press/103797 "2025-03-17T18:01:15Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jack.t](https://avatars.discourse-cdn.com/v4/letter/j/e79b87/32.png) [@jack.t](https://forum.inductiveautomation.com/u/jack.t)\
**Post date:** [March 17, 2025, 6:01pm UTC](https://forum.inductiveautomation.com/t/dynamic-label-update-on-button-press/103797/1 "2025-03-17T18:01:15Z")

</div>

Hi all.

I'm currently building in Ignition 8.1.45 perspective and having an issue that I can't understand..

I have 2 views (Sidepanel\_JT and Overview\_conv) the latter holds 3 buttons, CLR105, CLR106 and CLR107 - when pressed I want them to open up the Sidepanel\_JT dynamically so that the side panel opens and displays the conveyor name (CLR105).

This side panel holds 16 boolean states and LED's that will be dynamic based on which button is pressed:

If CLR105 is pressed, sidepanel opens (as embedded view) displays CLR105 at the top, and the LED's are binded via visibility and colour when TRUE and invisible when FALSE.

I have nearly everything working, except the label will just not update with the conveyor name - I've even written a script to output to the output console that each side is working (sending and receiving from views) and it works. - when nothing is pressed, for now, I have 'no conveyor selected' on the screen, which, again, works. But the buttons will not pull the text in!

Below is my current button script and layout:

def runAction(self, event):  
# Set the conveyor name dynamically based on the button pressed (e.g., CLR106)  
conveyor\_name = "CLR106" # Change this dynamically based on the button (CLR105, CLR106, CLR107)

```
# Update the selectedTag to set the tagPath
self.view.custom.selectedTag = {"tagPath": conveyor_name + "/CV/Status/State/Alarm"}

# Log the selected conveyor name to the console for debugging
system.perspective.print("Conveyor selected: " + conveyor_name)

# Pass the conveyor name as a parameter to the side panel
params = {"conveyor": {"conveyor": conveyor_name}} # The parameter being passed
system.perspective.print("Passing params to side panel: " + str(params)) # Log params being passed to side panel

# Set the session custom property to show the side panel
self.view.session.custom.showSidepanel = True # Trigger side panel visibility

# Set params in the session
self.view.session.custom.sidePanelParams = params # Set the params dynamically
self.view.session.custom.sidePanelTitle = "Side Panel - " + conveyor_name # Set dynamic title

```

And below is the script on my label field:

if(isNull({this.view.params.conveyor}), "No Conveyor Selected", {this.view.params.conveyor.conveyor})

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/5/65150761b1a6f2ef1c971ea820a2b631a61315a5.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/c/9c7d775d7233dd786c8ca4ccb3d5db595ce7a3a5.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/e/3ef80b16b7f16982627d1a7bae226156d0c5235f.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/2/028faafc8dbcbe5c9cb1ecbae97e243e0f04e4e0.png)

Sorry if the question isn't laid out too well, it was either this or the laptop out the window.

Thanks in advance

---

<div class="post-metadata">

**Author:** ![Kevin\_Flener](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@Kevin\_Flener](https://forum.inductiveautomation.com/u/Kevin_Flener)\
**Post date:** [March 17, 2025, 6:17pm UTC](https://forum.inductiveautomation.com/t/dynamic-label-update-on-button-press/103797/2 "2025-03-17T18:17:30Z")

</div>

I would create a session custom property and bind the label to it.

Then use the buttons to write to the session custom property. It's the easiest way I've found to pass a value to an embedded view.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [March 17, 2025, 6:35pm UTC](https://forum.inductiveautomation.com/t/dynamic-label-update-on-button-press/103797/3 "2025-03-17T18:35:22Z")

</div>

One problem that you may be having is that view parameters are only read once when the view loads. Changing them after that has no effect. @Kevin_Flener's solution is a good one.

Tip: Please see [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831).

---

<div class="post-metadata">

**Author:** ![jack.t](https://avatars.discourse-cdn.com/v4/letter/j/e79b87/32.png) [@jack.t](https://forum.inductiveautomation.com/u/jack.t)\
**Post date:** [March 18, 2025, 10:50am UTC](https://forum.inductiveautomation.com/t/dynamic-label-update-on-button-press/103797/4 "2025-03-18T10:50:13Z")

</div>

All good now Kevin, thanks for your help mate.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [March 18, 2025, 8:15pm UTC](https://forum.inductiveautomation.com/t/dynamic-label-update-on-button-press/103797/5 "2025-03-18T20:15:01Z")

</div>

I'd use a message handler. I have a profound dislike of session properties for anything that's not session related.

One example why: If you open a second tab and try opening that view for a different conveyor, it won't work. All tabs share session properties.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [March 18, 2025, 8:31pm UTC](https://forum.inductiveautomation.com/t/dynamic-label-update-on-button-press/103797/6 "2025-03-18T20:31:31Z")

</div>

> [@pascal.fragnoud](#):
>
> All tabs share session properties.

Agreed.  
Phil's Integration Toolkit's [pageVarMap()](https://www.automation-pros.com/toolkit/doc/scripting.html#pagevarmap) function gets around this, I think. I haven't tried it.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 18, 2025, 9:09pm UTC](https://forum.inductiveautomation.com/t/dynamic-label-update-on-button-press/103797/7 "2025-03-18T21:09:21Z")

</div>

It does. Applying it requires some mental adjustments, particularly letting go of page-scope messaging, and not writing directly to view or component properties that are tied to the pageVarMap.

---

<div class="post-metadata">

**Author:** ![Kevin\_Flener](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@Kevin\_Flener](https://forum.inductiveautomation.com/u/Kevin_Flener)\
**Post date:** [March 18, 2025, 9:35pm UTC](https://forum.inductiveautomation.com/t/dynamic-label-update-on-button-press/103797/8 "2025-03-18T21:35:24Z")

</div>

I hadn't considered that. My projects thus far have been simple self-use business apps, where I haven't needed to open multiple tabs.

@jack.t - It would probably be best to follow these suggestions from much more experienced persons.
