Write to Custom Session Properties

How do you write to custom session properties? I’m attempting to write to it from an actionPerformed script on a button, then switch the page afterwards. It’s a very simple script self.session.custom.client = self.getSibling("Dropdown").props.value when the next screen i show a label with the new value added to it but it still is retaining the old value. Is there a different way to write to session properties than writing to other types of properties?

How are you doing this? If this is a Script Action and then a Navigation Action, there is no guarantee of the execution order. If this is a single script which writes the value and then uses system.perspective.navigate() it should be working, and I would need to actually see the script to help you out.

Do you see any errors in the gateway logs when you trigger this ActionPerformed Event?

No, (Custom) Session properties behave just like any other property. In newer versions of Perspective/Ignition system-use session properties (most properties in session.props) will ignore write attempts.

It’s a script action, then a navigate action. The script function is just one line of code self.session.custom.client = self.getSibling("Dropdown").props.value and the navigate is a page navigation to another view, which is working. This system.perspective.navigate() function, where is the documentation on this? I looked in the user manual and i don’t see it. Is this function what i should be using?

Here’s the page in the documentation. I would recommend placing both the write and the navigation into a single Script Action. I would also place a logging call after the write but before the navigation just so you can temporarily see that it’s working.

system.util.getLogger('WRITEVERIFICATION').info('Write completed. New value: {0}'.format(self.session.custom.client))

To be clear: Navigation Actions are perfectly valid and work as intended, but when you have multiple Actions which trigger from a single event I don’t believe you get a say in which order they are executed as each is sent to be invoked on a new thread on the Gateway. It’s entirely possible your navigation action is being invoked before the property write, at which point the reference would no longer exist because you’re on a new page (however, I WOULD have expected an error to be displayed in the Gateway logs in this event).

Thank you for your help. I guess i was just over looking this function.