Creating & Managing Scripts

The Script Editor interface allows you to create, edit, test, and publish custom scripts for your Caseblocks instance. Scripts can be general-purpose or part of a lifecycle event (like preCreate or postDelete).

Script Editor

Header and Script Details

  1. Header
    • Displays the script name and its type (“Lifecycle” if it’s one of the predefined lifecycle scripts such as “precreate,” or “Script” for standard custom scripts).
    • Click Back to Scripts to return to the scripts overview.
  2. Script Details Toggle
    • Use the View script header / Hide script header button to show or hide extra script details.
    • When the script details section is expanded, you can edit:
      • Script name: The unique name for this script. This determines the URL you can use to access it (/{scriptName}).
      • Script description: A short text description of what your script does.
      • Make this a library function: Toggle if this script should be shared as a library function in your Caseblocks environment.
        • When enabled, you can call the script from other places with the notation: fn.{caseTypeCode}.{scriptName}.main(...).

Editing and Running Your Script

The main script editor is displayed within Tabs for easy navigation:

  1. Script Tab
    • Shows the editable JavaScript code for your script (the “draft” code).
    • You can run or save your script, and optionally make it live:
      • Run: Executes the current draft code using the chosen input. Results appear in the Output and Log panels.
      • Save & Run: Saves your draft code and immediately runs it with the current input.
      • Save: Saves your draft code without running.
      • Make Live: Publishes your current draft code so it becomes the version Caseblocks uses as “Live.”
  2. Live Tab
    • Displays the currently published (live) code for the script.
    • Shows the timestamp of the last save and indicates if the script is currently “Live” or “Not Live.”

Input, Output, and Log Panels

Under the Script Tab, you have three panels for debugging and testing:

  1. Input
    • Contains the JSON payload that your script will receive when executed.
    • You can type in or paste JSON directly.
    • You can also select a recent case from the Select an input case dropdown to automatically populate this panel.
  2. Output
    • Displays the JSON result of the script after you Run or Save & Run.
    • This is how you verify your script’s logic and final output data.
  3. Log
    • Shows any console or log messages produced by your script during execution.
    • Useful for debugging your code.

Switching Views: Column or List

If your screen is large enough, you can toggle between:

  • Column view (default), placing the Input, Output, and Log panels in side-by-side columns.
  • List view, which stacks them in a single column for narrower screens or personal preference.

Deleting a Script

To remove a script permanently:

  1. Click Delete Script at the bottom of the page.
  2. Confirm in the pop-up dialog. Once deleted, the script and all related data will be removed from the configuration.

Tip: Make sure to keep a backup of any critical script code before deleting it. Once a script is deleted, it cannot be recovered from within the user interface.


Copyright © 2024 Caseblocks Limited.