Skip to content
  • There are no suggestions because the search field is empty.

How to Debug Calculation Expressions

Learn how to debug calculation expressions in Smarter Drafter Pro.

Debugging calculation expressions in Smarter Drafter ensures that your calculations work as expected and return the correct results. If a calculation isn’t behaving as anticipated, debugging can help you identify and fix the issue. This guide will walk you through the steps to debug your calculation expressions in Smarter Drafter.

Instructions

1. Navigate to Your Form

  • Open the form where you’ve set up the calculation expression that needs debugging.

2. Access the Field with the Calculation

  • Locate the field where the calculation expression is applied. This could be a field for sums, dates, conditional logic, or any other type of calculation.

3. Open the Calculation Tab

  • Click on the Calculation tab for the field you want to debug. This will open the Calculation Builder tool, where you can review the expression and troubleshoot.

4. Review the Expression

  • Carefully review the calculation expression in the builder. Check for common errors, such as:
    • Mismatched parentheses: Ensure that all opening and closing parentheses are correctly paired.
    • Incorrect field references: Verify that the fields referenced in the expression exist and are properly named. Field references are case-sensitive, so ensure accuracy.
    • Missing operators: Check for missing operators like +, -, *, or /, especially in complex expressions.
    • Improper syntax: Ensure that the syntax is correct, such as the proper use of IF THEN ELSE statements or mathematical operators.

5. Test with Sample Data

  • Enter sample data into the form to test the calculation. This will help you determine if the expression works as expected. If the result is not as expected:
    • Check for zero or null values: If your calculation involves division, ensure that no fields contain zero or null values that could cause errors.
    • Verify the field type: Ensure the field type matches the type of data you are working with (e.g., number fields for maths, date fields for date operations).

6. Use the Expression Summary

  • Some fields, like the ones with conditional logic, will provide an expression summary in the Calculation Builder. This summary shows the calculation in more readable terms (e.g., using field names rather than field IDs). Use this summary to double-check that the logic makes sense.

7. Simplify the Expression

  • If the calculation is complex, try simplifying it temporarily to isolate the issue. Start by breaking it into smaller components and testing each one individually. For example:
  • If you're adding multiple fields, test each field addition individually to ensure they are correctly adding up.
  • If using conditional logic, test each condition separately to see if it's behaving as expected.

8. Use Logs (If Available)

  • If available in your system, check the logs for any errors related to the calculation expression. Logs may give you a more detailed view of any issues.

9. Check for Updates or System Errors

  • Occasionally, an issue with a calculation might be caused by a system error or outdated version of Smarter Drafter. Ensure that your platform is up-to-date and check for any known issues or updates that might affect calculations.

10. Test After Each Change

  • After making changes to the calculation expression, test the form again with new data to ensure the problem is fixed. Debugging is often an iterative process, so make small changes and test frequently.

11. Save the Corrected Calculation

  • Once the expression works as expected, click Save to save the corrected calculation.


Common Issues & Solutions

  • Issue: The calculation returns a blank or incorrect result
  • Solution: Check for missing or incorrect field references. If the expression relies on other fields, make sure those fields are populated before the calculation occurs.
  • Issue: Division by zero error
  • Solution: Ensure that any division operations are checked for zero or null values before being performed. You can add conditions to prevent division by zero errors.