FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
Dear Community User! We have started the migration process.
This community is now in READ ONLY mode.
Read more: Important
information on the platform change.
02-29-2024 03:53 PM
How to refresh Local Script according to some variable has changed. F.e. my local script generate table according to page number: if pageNumber = 1: generate 10 first row of the table, pageNumber = 2: next 10 row. Now, when I've changed pageNumber I need to change view and return back. But how it makes automatically? How observed pageNumber and refresh LS when smth was changed?
Solved! Go to Solution.
02-29-2024 04:17 PM
You cannot "refresh" a LocalScript (as you cannot "refresh" a JavaScript) - a LocalScript is only executed once per access (because a Javascript is only executed once per access). If you include it in the topmost area (i.e. not inside any screen) it will be executed exactly once after a user has logged in.
When you want to change a view when a item changes you can simply subscribe to the item in your LocalScript and change the view on change (and don't forget unsubscribing in the onDisable function). You can find examples in the scripting demo. Please familiarize yourself with that demo as it shows a lot of examples.
However, I assume you want to do something completely different: if you simply want to show a specific view in a panel widget when a specific item changes you can simply add an item to the panel so if your item is 0 it will show the first view, if it is 1 it will show the second etc.
Please note that it's always best to describe what you want to achieve in the first place.