Can you reference a view parameter in a Tag Event Value Change Script?

Since I have an application I'm making for 2 identical machines, I had set up a lot of indirect tags utilizing a view param "Nip_Press" (set to 1 or 2). I was able to use "self.view.params.Nip_Press" or "view.params.Nip_Press" to utilize it in indirect tag references or components. I've been looking through the docs and other forum posts, but I haven't found one that explains how to do so? Can I even reference that view parameter in a tag event script? Obviously the button shortcut for view / session properties doesn't show up in the script editor... so I'm not sure if it's possible?

1 Like

No. Session/page/view/component properties are only available in the scope where they are defined, and inner scopes.

If you need properties in your UI to drive global values available to global scope, it is common to create memory tags and bidirectionally bind the UI properties to the memory tags. (Not necessarily the only way...)

@pturmel,

Ah, that's fair and what I was expecting. I guess creating another tag isn't that bad to get to what I'm trying to do. I don't even need to bidirectionally bind, as it's set once and done.

Thanks!

Follow-up; I also realized that I didn't even need to do any of this in the first place; since I had organized each machine as it's own folder / set of tags, I could just use [.] to be in the same directory.... so I didn't even have to indirect reference the tag path.

2 Likes

For the next time you encounter this issue: Don't pass the machine's number, pass the base tag path, then use that.
ie, you have a folder named "machines", containing 2 UDT instances named "machine1" and "machine2", each containing the tags "temperature", "pression", "whatever".
Instead of passing "1" or "2" to the view, then using this to build the path with something like machines/machine{machine_number}/temperature, pass it "machines/machine1" then build the tag path like this: {machine_path}/temperature, {machine_path}/whatever

3 Likes

@pascal.fragnoud,

I understand that that's another way to reference, but what is the advantage of that? Isn't that effectively the same thing, just formatted differently? I've included a picture of my tag group for reference. In this case wouldn't saying "[LPP_Nip_Presses]NIP_Press_{Number}/Scanner_Counter" be the same as saying path = "[LPP_Nip_Presses]NIP_Press_1", "{path}/Scanner_Counter"? Or is there a functional difference between them?

image

What happens when you need to use the same view for a machine that's in a different folder, follows a different naming convention or is in another tag provider ? You're screwed.

1 Like

Ah. That's fair.