Skip to content

Introduction to Scripting Functions

It is possible to write scripts within BizzStream in order to automate company-specific logic and extend the application's capabilities.

JavaScript as the Script Language

BizzStream uses JavaScript as its main language. This means you can use standard JavaScript features like defining and calling functions, using loops (for, forEach, while), conditional statements (if/else), and working with standard data types and built-in objects (such as Array, Object, Math, Date, String methods). If you're new to JavaScript, many good online resources can help you learn the language.

Some good online courses are:

There are also two additional libraries that are documented here: Additional Scripting Libraries

System Mode Execution

Scripts in BizzStream run in system mode. This is a crucial concept: it means that scripts always have full access to all documents and data within the application, regardless of the permissions of the user who triggered the script or the workflow action (Only the environment where the script is ran). Because scripts run in system mode, they do not take the permissions of the user starting the action into account.

Scripts can be executed as part of workflow actions, allowing you to automate complex processes that require system-level access to data. Another good way to use the automation process is with using scripts in combination with events.

This document serves as a reference for the functions available specifically within this scripting environment, complementing the standard JavaScript features you can use to interact with the system, trigger actions, communicate with users, and integrate with other parts of the application. Understanding these functions will allow you to build custom logic and tailor the application to specific workflows and requirements.

Available Scripting Functions

Below is a list of the available scripting functions, grouped by their primary area of functionality, along with a brief description of their purpose and when you might use them.

All functions are linked to the additional documentation. Press the function name to go directly to the correct document.

BizzStream Functions

These functions allow your scripts to interact with core BizzStream functionalities, such as navigation, user management, and communication.

Function Description
bizzStream.goToURL Use this to direct the user to a specific web address from within a script, useful for linking to external resources or other parts of the application accessible via URL.
bizzStream.sendMail Use this to send automated emails based on script logic, such as sending notifications, alerts, or automated reports to users or groups.
bizzStream.addUser
  • Use this to programmatically add new users to the system or modify details of existing users, useful for user onboarding or data synchronization scripts.
  • (Note: bizzStream.addUserV1 is an older version with a different parameter format).
bizzStream.getUser Use this to retrieve information about a user based on criteria like ID, username, or email, useful for fetching user details within a script or checking user existence.
bizzStream.emitEvent Use this to trigger application-defined events from a script, allowing for integration with event-driven workflows or custom application logic that responds to specific events.
bizzStream.sendPushNotification Use this to send push notifications to users.

Notification Functions

These functions allow your scripts to display messages directly to the user interface, providing feedback or alerts.

Function Description
notification.info Use for displaying general information messages or process updates to the user.
notification.success Use to indicate that an operation requested by the user or performed by the script has completed successfully.
notification.warning Use to inform the user that an error occurred during script execution or a requested operation failed.
notification.error Use to inform the user that an error occurred during script execution or a requested operation failed.

Persistent Functions (Data Storage and Retrieval)

These functions interact with the application's database, allowing scripts to create, read, update, and delete documents and manage attachments.

Function Description
persistent.saveDocument
  • Use to immediately save a new document or update an existing one in the database.
  • There is also a Lazy function for saveDocument.
  • (Note: persistent.saveDocumentV1 is an older version with different behavior regarding data conversion).
persistent.findDocuments
  • Use to search for and retrieve documents from a specific document definition based on query criteria and options (like sorting or pagination).
  • (Note: persistent.findDocumentsV1 is an older version).
persistent.getDocument Use to retrieve a single document when you know its specific document definition name and unique ID.
persistent.deleteDocument Use to permanently remove a specific document from the database when you know its document definition name and unique ID.
persistent.addAttachmentsLazy
  • Use to add one or more attachments to documents in a lazy manner, staging the addition for later processing.
  • (Note: persistent.addAttachmentsLazyV1 is an older version with a different parameter format).
persistent.copyAttachments
  • Use to immediately copy one or more attachments from a source location to a target location within or between documents.
  • There is also a Lazy function for copyAttachments.
  • (Note: persistent.copyAttachmentsV1 is an older version with a different parameter format).
persistent.removeAttachmentsLazy
  • Use to remove specific attachments from documents in a lazy manner, staging the removal for later processing.
  • (Note: persistent.removeAttachmentsLazyV1 is an older version with a different parameter format).

Console Logging

  • console.log(message1, message2, ...)
    • When to use: Use for debugging your scripts by printing information (like variable values or execution flow) to the administrative log screen.

Data Ordering

When working with functions that retrieve multiple documents, such as persistent.findDocuments, you often have the ability to specify the order in which the results should be returned. This is typically controlled through an sort parameter passed to the retrieval function, rather than through separate "order functions". The sort object for findDocuments would contain properties to define sorting criteria (e.g., field name, ascending/descending order).

Creating a script

Please take the following steps to create a new script:

  1. Go to Settings. Settings Icon
  2. Go to Scripts. Scripts Icon
  3. Add a new one and give the script a label and a name. Scripts Icon
  4. Click the Save button to persist the script. Save Icon