Order of execution and the effect of Navigation upon it

Hi all,

Firstly, this does work, however, I dont understand why!

I have a 'On Click' script on a object that is designed to set a session prop called 'TabSet' to a number, then change the page. The destination page has a tab container that looks at this value 'Onload', and if its not zero, it sets the tab container to the requested tab number.
In a nutshell, a way of navigating to a different page and setting the tab number if needed.

I assumed the script should be this, because we first set the prop, then we navigate to the page meaning we know our prop is set before we go.

def runAction(self, event):
	# Request Tab Number on Destination Page
	self.session.custom.tabSet = 8
	
	# navigate to the required page
	system.perspective.navigate('/p&id/filling')

However, this does not work.
If I switch the order to ask for a navigate and then set the tab, it works!

def runAction(self, event):

	# navigate to the required page
	system.perspective.navigate('/p&id/filling')

	# Request Tab Number on Destination Page
	self.session.custom.tabSet = 8

However... I do not understand why. Surely if we are starting to navigate, and the loading time is too quick, the prop change could be missed?
Why is the prop not set before the script moves on to the navigate line? Does the navigate cancel the prop set?

Noted, this is the same if I use 2 different actions, a script to set the prop, and then a navigate type event.

I'm guessing theres some form of execution order here I dont understand, but would very much like too :slight_smile:

Thanks!
Alex

I would need more insight into the project to explain why this is working for you because you're right - it shouldn't be. your non-working example is "more correct" than the working example, although this seems like an excellent location to use page parameterization.

system.perspective.navigate('/p&id/filling/8')

or

system.perspective.navigate(url='gatewayAddress:port/data/perspective/client/projectName/p&id/filling/?tabSet=8')

Don't use two separate actions.

Without understanding more about how the other View/Page is configured - and having more insight into the 'Onload' script - I won't be able to tell you why what you're doing now is working. I'm hoping you mean an onStartup Event for the View, but, again, I'd need to see what you're doing on the other Page to really help out here.

2 Likes

Thanks for confirming I'm not going mad! :slight_smile:

I had forgotten about page parameterisation entirely as I haven't had to use it yet, so will switch to that solution ... but for context and SCIENCE! My configuration is as follows:

An object in a coordinate container on page_1 has a mouse onclick event with the scripts in message 1 (lets take the not working on for now).

I have added a custom session property called 'tabSet' with a value of 0, not bound to anything.

On 'Page 2' (destination) we have the below:
image

And this tab container has the following event:

However ... this evening I cannot replicate the error! I do have some strage things happen when I plug in and run on an external monitor, so will post a follow up tomorrow when Im back onsite. Watch this space!