I have a requirement in Perspective. I have a custom property that gets its value when a user logs in. I want to pass that custom property to a function in the project library. Is it possible to pass a custom property to a function like this? Has anyone done it before? If yes, please let me know how to do it or suggest a solution.
Add an additional argument when defining the function in the project library script and pass in the property via that argument when calling the function. Very common practice, as many pass the reference to the entire view or view custom properties when scripting.
Understood. In my case, the function is being called from a Gateway Timer Script, not from a component or expression. The function resides in the project library and currently accepts a parameter.
However, I want to pass a custom property value (from a Perspective view) into that function. Since Gateway Timer Scripts run on the gateway scope and don't have access to session or view context, I'm looking for a way to pass that custom property value to the function when the user logs in or when the view is loaded.
Is there a recommended approach for making a Perspective custom property available to a Gateway-scoped script, or is there a workaround using a tag or database?
No, as they are not available to gateway-only scripts.
The most common approach would be to use a tag. But keep in mind that tags are share among all users. What do you expect to happen when you have more than one Perspective client running?
I.e. have the timer script send a message to the perspective project on message channel A
then the perspective project has a handler that sends back the custom prop on channel B
then the gateway has a handler on channel B that runs the actual script