Dynamic label update on button press

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})

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

Thanks in advance

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.

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.

All good now Kevin, thanks for your help mate.

1 Like

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.

2 Likes

Agreed.
Phil's Integration Toolkit's pageVarMap() function gets around this, I think. I haven't tried it.

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.

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.