Skip to main content

Verifying Script Functionality

Symptoms

A script fails to execute if there are syntax errors or runtime issues, such as missing variables or incorrect logic.

It can also fail if the script is not properly triggered (e.g., a failure in a preceding action like a trigger or DTMF input), the script may not run as expected. 

Cause

Issues with a script are likely caused by one or more of the following:

  1. Not running: The action that triggers the script to run may not be setup correctly, or may have an issue.
  2. Syntax Errors: The script might contain invalid syntax (like missing punctuation) or incorrect code structure. These errors can usually be detected by the system.

  3. Runtime Errors: Even if there’s no obvious syntax error, the script could fail during execution due to logical errors or missing data.

Solution / How To

1. Check if the script was executed

Navigate to the "Programming / Scripts" section (or "System / Scripts" in versions before 5.1.0) image.png

Here you should see that the script was executed.

 

Confirm that the script has been executed. If not, refer to the appropriate article based on how the script is triggered:

image.png

2. Check the script for (syntax) errors

Open the script where you suspect the issue.

Look for common issues like missing semicolons, undefined variables, or incorrect values.
image.png
Scroll down to "Info / errors / warnings" to check for errors. image.png

3. Review the Logbook

Navigate to the "logbook" tab. image.png

Look for warnings or runtime errors. These may give more insight into what went wrong, even if there are no obvious syntax errors.

 

In this example case, the script has logged a warning that indicates an invalid / unexpected value of a specific variable.

image.png

4. Fix Any Errors Found

If you see any syntax issues, such as a missing semicolon or an undefined variable, fix them.

 

In the first example case we changed $message = '' to $message = ''; since a semicolon was missing here.

image.png



5.Test the Script (Again)

After any fixes have been made, we should test the script to see if any issues still occur.

 

Click the "Execute script now" button to preform a test.

image.png

If a source and/or value are required for the script, fill these with the data the script might expect.

 

Like in the example a call from a tag, where the source is the tag name, and value the tag value.

image.png

Click the "Execute script now" button to execute the script.

image.png

After this you can follow step 2 - 4 until there are no more issues.


1. Check the script

Navigate to "Programming / Scripts" (or "System / Scripts" in versions before 5.1.0)

 

You may already be able to see that there is an error from this list, like in this case.

image.png

Open the script where you suspect the issue.

image.png

Scroll down to "Info / errors / warnings" to see if there are any (syntax) errors for the script.

 

In this example case we can see that there was a syntax error with the line $message = '' since we forgot to end the line with a ; character. So to fix this we change this line to $message = '';.

 

image.png

2. Check the script logs

Since some scripts may not have any syntax or other errors under the "Info / errors / warnings" header but still don't work, we should also check the log book for any logs created by the script.

 

Navigate to the "logbook" tab.

image.png

Check the logbook for this script, for any issues.

 

In this example case the script has informed us that our $message variable was empty, and asked us to fill it in for the script to work as intended.

image.png

References

For more in-depth troubleshooting and information on how to manage scripts, refer to the following resources:

  • PHP Syntax - Detailed information on (PHP) scripting syntax.