Pass string array as parameter to popup

All - I am needing to pass an array of tag paths to a popup which will ultimately return a csv of the passed in tags’ history. However, the only way I can get this to work is to hard-code the paths. I have included screen shots in hopes that I’ve missed something simple. I have no idea if I am passing the paths parameter correctly or if any type-casting needs to happen.

Any help is appreciated. Thank you.

Parameter declaration on the popup view:
Annotation 2020-08-20 104611

Passing of the parameter to the popup:
Annotation 2020-08-20 104857

Label on the popup which is bound to the paths parameter (just to verify what’s being passed):
Annotation 2020-08-20 1105

Script which is fired when the ‘Export To Csv’ is clicked:

The exception in the gateway:

It looks like you’ve added some lines to your code AFTER you received the error message. Could you please provide the code as it is when the error is encountered?

What the problem LOOKS to be is that you’re attempting to pass a String (not a string array), and so the paths arg in the queryTagHistory function is failing. Your # Does work assignment of tagPaths works because it is actually a list of Strings, which is what the arg expects.

I would try the following:

  1. create a custom property somewhere within your view to store the paths you want to use (mine is a custom property of the Button)
  2. In the Popup Action dialog, identify the property you want to pass by using the property popover.

Please keep in mind that my recommendation is based on the assumption that lines 5 and 6 of your code screenshot were introduced AFTER you received that stacktrace. One thing you could also check is to print out the type of tagPaths after each assignment to see what you’re dealing with:

tagPaths = self.view.params.paths
# probably unicode
system.perspective.print("tagPaths type: {0}".format(type(tagPaths)))
tagPaths = ['[default]First', '[default]Second']
# probably list (or PyList)
system.perspective.print("tagPaths type: {0}".format(type(tagPaths)))

Nice. So, like you, I added a custom property on a button, passed that to the popup, and it worked as expected. Is there a way to set the value of the array parameter (paths) inline - via the Configure Popup Action screen - along the lines of what I was originally doing? Thanks.

Not when the value is an array. Those inline fields are single-value fields. You could pass a single string value and parse it within the Popup, but that’s a hassle. What I personally recommend is only using the Popup action for the simplest of Popups. Any time I need to perform any Action which is not of the “simple” variety I ALWAYS use a Script Action and use a perspective package scripting method.

paths = ['[default]First', '[defaultSecond']  # or specify a property instead of a hard-coded list
system.perspective.togglePopup(id='mycsvpopup',params={paths=paths})

If you look at the documentation, you’ll see that it allows for a much more dynamic setup as the behaviors can be dynamically changed at runtime and the params can be more than a single-value.

Great. Appreciate the help!

1 Like