How to pass parameters using system.perspective.navagate

Hello All,

I am trying to edit the data on Table Component. I came across a great video that give a basic example of how to do so but I am having a bit of a problem passing the parameter to the new view. In my example, I am selecting a column and I have a button that starts the navigation. Like in the video, I have a custom property attached to my table. But I am using an OnSelectionChange event to update its value. With my button, the navigation works fine. I am navigating like this: system.perspective.navigate(view = "Objects/Next View", payload={'key':str(self.parent.getChild("FlexContainer").getChild("table").custom.myCustParam)})
The Custom Parameter on the view being navigated to has the same name and case as the Custom Parameter on the table but it does not update when the view is navigated to. Can anyone help me to figure out why the parameter is not updating?

Thank you in advance,

Israel

Check out message handlers, I think that is how you need to pass your parameters.
https://docs.inductiveautomation.com/display/DOC81/Component+Message+Handlers

The documentation for the navigate function does not list a payload kwarg - I think you might want to use params instead. Also, you’re sending your parameter to a property named key in your current code. I’ve modified your code to pass the expected param.

system.perspective.navigate(view="Objects/Next View", params={'myCustParam':str(self.parent.getChild("FlexContainer").getChild("table").custom.myCustParam)})

Thank you for your reply @cmallonee. I have applied the changes you have suggested but I am still unable to use the value in the view being navigated to. In the root of that view, I have my custom parameter “myCustParam” and I have another custom parameter which is a dataset that should be using the “myCustParam” parameter in it’s where clause. I am trying to figure out why the parameter never changes or why it not being passed. Do you have any other suggestions that I might be able to try?

Thanks for your quick reply @josborn. When writing this post, I failed to mention that I have actually tried passing a message to the new view in the onSelectionChange event. The problem that I had with that is the view is not open at the time the message was sent. I have log statements that print when the MessageHandler receives the message. But I cannot get any of the log statements to print unless I am using the preview mode in the Designer and the view being navigated to is already open. I have also tried to use the navigate function and immediately use the sendMessage function to send a message to the view being navigated to but that doesn’t seem to work either. The example that I mentioned in my post was not for perspective. Should I be going about this in a different way since I am using Perspective?

It's hard to tell if this is a terminology concern or not, but "root" nodes do NOT have params - only View nodes do. If you do not have params.MyCustParam, then none of this is going to work.

Please provide the code as you have it currently, as well as a screenshot of the params of the View in question.

I just attempted this myself in 8.1.12rc1 and it works exactly like I would expect, so there is either a configuration issue with the View in use, or your code. If you could supply the view.json file of the View you are attempting to navigate to I could examine it and provide the exact code you need to use.

Thank you for your response. Sorry for the confusion. I am using views. The “root” that I referred to is the root container (In the Project Browser tree, it is the element directly under the View name).
This is a screenshot of the custom parameter that is on the Table.
image

I am setting the parameter in the onSelectionChange like this:

self.custom.myCustParam = 11

In my button, I have an onActionPerformed event that sends does the navigation like this:

system.perspective.navigate(view = "Objects/New View",params = {'myCustParam':str(self.parent.getChild("FlexContainer").getChild("Table").custom.myCustParam)})

This is a screenshot of the view that is being navigated to:
image

That’s not how you receive params for the View. The named View node must have the param set within the params category or properties. You should then update any bindings against self.root.custom.myCustParam to self.view.params.myCustParam.
Screen Shot 2021-11-09 at 11.24.45 AM

Please review the documentation.

That worked! Thank you so much for your help!

1 Like