How to test and troubleshoot scripting
When writing new scripting for event rules, the device mapper, and click scripts, learn how to ensure the scripting works as expected.
How can I test my script with real asset data?
You can test the scripting in the editor. Choose the track point from the track point list, and the value of the asset will be loaded into the script console automatically.
Can I simulate inputs/variables when testing the scripting?
Of course! You can add any variable in the editor and input the value for your testing scenario. From the Script Editor window, on the right-hand side, there is the Fields category where you can select any variable and press add.
How I can troubleshoot if the scripting is running in the correct logic as expected?
The log() method! It is beneficial when troubleshooting scripts. Use the log() method to write down values and then check if they really are what they should be. log() writes down messages to the terminal when the event rule is running.
When you test run the script in the editor, log() writes messages to the output console.
Log () writes messages to the App Console when you are testing the click script. You can find it from Main Menu > Admin > Development > App Console.
In summary, there are a few key things in the script editor that are the golden combination for script testing:
- the Test Script button
- setting variable values in the editor
- using the log() method