How to pass tags into a popup perspective

Hi there,

So I have become very good at using Ignition with Visions and now I am transitioning to perspectives. I understand mostly how they work. However, I am used to in the vIsions I can create templates of say a valve and when the users clicks it a popup shows up and is populated using a UDT so that making multiple valves is quick and easy. I understand how to make popups but how would I go abouts passing say a UDT that has lets say a string, int. And make this dynamic so I can use it multiple times. I've gone through the perspective university videos but nothing really talks about passing tags over.

EDIT:

I think I figured it out. I am assuming I have to use the custom property and just pass each tag individually instead of a udt?

I've never used Vision, but I usually pass the UDT's path and bind indirectly in the popup.

1 Like

Where abouts would you do that?

| nideyijuyidong
January 24 |

  • | - |

I've never used Vision, but I usually pass the UDT's path and bind indirectly in the popup.

https://docs.inductiveautomation.com/display/DOC81/Popup+Views
For diffirent valves,pass a diffirent UDT path, then use the params in popup page.

Vision's UDT-type parameters basically couldn't be brought over to Perspective's JSON-centric world, so they weren't brought over wholesale to Perspective. The generally preferred pattern is to pass a tagpath string, and use indirect bindings over well known tag paths. This is actually a bit more flexible than Vision's UDT bindings, since two UDTs just have to be structurally similar (i.e. following the same folder and naming convention) to be used by the same "template" view.

And it is precisely why I always argue against using UDT properties in Vision, either.

1 Like

Sorry do you have an example of this?

There's not much to demonstrate as an example, really.
Make one view. Give it a parameter named 'tagpath' (or whatever) and make it an input parameter.
Put a label or something else on the view, use an indirect binding to bind to {self.view.params.text}/SomeTagInTheUDT.

Then create a containing view, and use an embedded view, or a flex repeater, or whatever other component you want, to instantiate the 'child' view and set the tagpath parameter to the path to your tag. The indirect tag binding should automatically pick up and start working.

Expanding on the example from @PGriffith , you would then open a Popup in the following manner:

system.perspective.openPopup(id="SomeUniqueValue", view="MyView", params={"tagpath": "pathToUdt"})

Hi @brandon222
Even if you don't need the ressource you can find in there how to link tag to a faceplate and from in this faceplate call a popup with input parameters.

Regards

Ok thank you all I think I figured it out. However, I have one other question. How do I get the page to refresh as data updates. For instance when I pass an int over for a CylindricalTank it works fine and show the percentage. But when and change the value of the tag it doesn't update on the screen.

That's what you get when you pass a value. To get updates, the receiving view needs to have a binding. That's why you should pass a tagpath--so the view can bind to the source instead of getting a snapshot of the source.

As @pturmel said: You're passing an un-changing param value. If you need some UI to update based on changes, then you need to use that value to create a binding. This is a good example of why you should pass a reference to what stores your value rather than the value itself.

I'm sorry is there anyway you can show this to me in a screenshot or something. I'm very big visual learner so that would help me understand it properly. I'm sorry

1 Like

Get ready for a weird analogy.
Think of a tag path and its value as a person and their weight.
If you ask for someone's weight, they (might) give you a value at that date and time.
If you assume in 10 years that their weight is still the same, you will most likely be wrong; you need to ask them again.
However, if you instead know the person's name (their ID) and there's a global database of people with up-to-date info on their weights, then you can find out that person's current weight since you know their name/id.

You need to pass the person's name (the path to the tag) to the popup, not its value. Then in the popup you need to use an indirect tag binding that uses the tag path you pass in.

Thank you for that analogy makes perfect sense. My problem is I don't know where abouts I would put that information into the perspective screens.

1 Like

I never used UDTType params in Vision either, which meant I couldn't use the drag/drop UDT Instance onto Window to auto add Templates either. But I've always wondered if similar drag/drop functionality made it into Perspective? In a different form, obviously since UDT type params don't exist.

Here's a super simple example:
UDT Popup Test.zip (8.6 KB)

The button opens the popup, passing in a deviceParentPath and deviceName. These should make up the path to the UDT instance, where they're combined in the popup into a custom param deviceTagPath as: {deviceParentPath}/{deviceName}
So for example, if the path to your UDT instance is: area/sub area/pump 1, then you should pass in the params like this:
deviceParentPath: 'area/sub area'
deviceName: 'pump 1'

The popup then displays a "Status" tag which is part of the UDT Instance using an indirect tag binding:
{deviceTagPath}/Status

Notes:
The reason I pass in deviceParentPath and deviceName instead of just deviceTagPath, is:

  • for simplicity of populating these within the embedded view's params since you can then set the parent path for multiple objects which are all in the same folder
  • the property window cuts off long strings, and the deviceName is the most important part. If the full path was copied in instead of splitting these up, then the device name would most likely be cut off in the display
  • it makes it easy to display the device name in the popup

Not exactly. There's a customizable (but somewhat obscure) way to set up your own component bindings easily, but only for native data types:
https://docs.inductiveautomation.com/display/DOC81/Perspective+Project+Properties#PerspectiveProjectProperties-PerspectiveTagDropProperties

I did see these in the project settings, and it looked ok, but I very rarely drag tags directly onto the page to create the graphics for them, so it's not all that useful for me personally. It would be useful to be able to do something like this for UDT instances though. All of my device template Views have a deviceParentPath and deviceName, so it would be nice to be able to specify a list of UDT types to apply auto mappings to.

1 Like