Skip to main content

Input Output

Input/Output parameters allow you to process and transform data before and after task execution in your process workflows. This powerful feature supports three types of operations: Scripts, Expressions, and Actions.

Input/Output parameters are available for:

1. Parameter Typesโ€‹

TypeDescriptionUse Case
ScriptJavaScript code executed server-sideComplex logic, calculations, API calls
ExpressionString ValueVariable with a static string value
ActionVisual function builderUI operations, database queries, file handling
Input/Output Parameters Overview Interface
Input/Output Parameters Overview Interface

The Input/Output parameters interface provides a centralized location for managing data transformations before and after task execution, with support for scripts, expressions, and visual action builders.

2. Input Parametersโ€‹

Input parameters are executed before the task runs, allowing you to:

  • Transform external data for task consumption
  • Set up task-specific variables
  • Prepare data from previous tasks
  • Initialize default values

3. Output Parametersโ€‹

Output parameters are executed after the task completes, allowing you to:

  • Process task results
  • Transform data for the next steps
  • Update process variables
  • Save results to databases

4. Script Parametersโ€‹

Scripts use JavaScript and run in a secure server-side environment with access to the Softyflow SDK.

Script Parameter Editor Interface
Script Parameter Editor Interface

The script parameter editor offers a complete JavaScript development environment with syntax highlighting, variable access, and SDK integration for implementing complex business logic and data transformations.

4.1. Available Variables in Scriptsโ€‹

The following variables are globally available in the script execution context:

  • Process Variables: All variables currently active in the process instance.
  • SF_initiator: An object containing information about the user who started the process.
  • SF_latestValidator: An object with details about the user who last validated a task.
  • volt: A global object for accessing configuration variables.
  • SF: The Softyflow SDK instance, providing access to a wide range of backend functionalities.

4.2. SDK Function Examplesโ€‹

Here are a few examples of what you can do with the SDK:

SDK Usage Examples
// --- Database Operations ---
// Find active users in the "users" collection
const activeUsers = SF.collection.find("users", { status: "active" });
// Insert a new document into the "orders" collection
SF.collection.insertOne("orders", { product: "New Laptop", quantity: 1 });

// --- File Operations ---
// Upload a file
const fileId = SF.file.upload(fileData);
// Download a file
const downloadedFile = SF.file.download(fileId);

// --- User Operations ---
// Retrieve a user by their ID
const user = SF.user.getUserById(userId);
// Update a user's metadata
SF.user.updateUserMetadata(userId, "preference", "dark_mode");

// --- Process Operations ---
// Launch a new process instance
SF.instance.launchProcess("process_definition_key", {
initialVariable: "value",
});
// Validate a user task and pass data
SF.instance.validateTask(taskId, { taskResult: "approved" });

5. Expression Parametersโ€‹

Expressions are simple text expressions.

Expression Parameter Editor Interface
Expression Parameter Editor Interface

The expression parameter interface enables simple string value assignments without complex scripting, ideal for static values, basic variable mapping, and straightforward text assignments.

6. Action Parametersโ€‹

Actions provide a visual interface for building complex functions without writing code.

Action Parameter Visual Builder Interface
Action Parameter Visual Builder Interface

The action builder provides a no-code visual interface for creating complex workflows by connecting pre-built operations like database queries, API calls, and file handling without JavaScript programming.

6.1. Available Action Categoriesโ€‹

  • Database Actions

    • Find Collection: Query database collections
    • Insert to Collection: Add new documents
    • Update Collection: Modify existing documents
    • Delete Document: Remove documents
    • Aggregate Collection: Complex database queries
    • SQL Operations: Direct SQL database operations
  • Process Actions

    • Launch Process: Start new process instances
    • Validate Task: Complete pending tasks
    • Get Pending Task: Retrieve task information
    • Update Instance Variables: Modify process data
    • Get Measures: Retrieve process metrics
  • User Management Actions

    • Find Users: Search user database
    • Find User By ID: Get specific user
    • Update User Metadata: Modify user preferences
    • Get User Metadata: Retrieve user data
  • Utility Actions

    • Get Next Value: Generate sequential numbers
    • Call API: External API integration
    • Generate PDF: Create PDF documents
    • Send Email: Email notifications

7. Configuration Interfaceโ€‹

This comprehensive configuration panel offers drag-and-drop parameter management, real-time testing capabilities, and validation tools to ensure your data transformations work correctly before deployment.

Input/Output Configuration Panel
Input/Output Configuration Panel

7.1. Adding Parametersโ€‹

  1. Open Task Configuration: Select any task in the process modeler
  2. Access Input/Output Section: Scroll to the Input/Output section
  3. Add Parameters: Use the + buttons to add new parameters:
    • Add Script: For JavaScript code
    • Add Expression: For simple expressions
    • Add Action: For visual function building

7.2. Parameter Managementโ€‹

7.2.1. Drag & Drop Orderingโ€‹

Parameters execute in order from top to bottom. Use the drag handle to reorder:

๐Ÿ“‹ Parameter 1 (executes first)
๐Ÿ“‹ Parameter 2 (executes second)
๐Ÿ“‹ Parameter 3 (executes last)

8. Best Practicesโ€‹

tip

8.1. Performance Optimizationโ€‹

  • Use expressions for simple operations.
  • Use scripts for complex logic.
  • Use actions for database operations.
  • Minimize external API calls in critical paths.

8.2. Error Handlingโ€‹

A robust script should always include error handling to prevent process failures.

Robust script example
try {
let result = complexCalculation(inputData);
return result;
} catch (error) {
console.error("Calculation failed:", error);
// Provide a fallback value or re-throw the error
return defaultValue;
}

8.3. Variable Naming Conventionsโ€‹

  • Descriptive Names: Use clear and descriptive variable names (e.g., customerEmail instead of email).
  • Consistent Convention: Follow a consistent naming convention, such as camelCase.
  • Avoid System Prefixes: Do not use system-reserved prefixes like SF_ to avoid conflicts.

9. Advanced Featuresโ€‹

9.1. Dynamic Variable Namesโ€‹

// Set variables dynamically
let variableName = "user_" + userId;
variables[variableName] = userData;

9.2. Conditional Executionโ€‹

// Only execute if conditions are met
if (orderTotal > 1000) {
return applyDiscountLogic();
}
return orderTotal;

9.3. Multi-Instance Processingโ€‹

For sub-processes with parallel instances:

// Access loop variables in sub-process
let currentItem = SF_loop_variables;
let itemIndex = SF_loop_index;

9.4. System Variablesโ€‹

The following system variables are always available in both scripts and expressions, providing important contextual information about the running process:

  • SF_initiator: Information about the user who initiated the process.
  • SF_latestValidator: Details of the user who last validated a task.
  • SF_mode: The current execution mode, which can be test or prod.
  • SF_version: The version of the process definition.
  • instanceId: The unique identifier for the current process instance.
  • projectId: The identifier of the project to which the process belongs.

10. Troubleshootingโ€‹

10.1. Common Issuesโ€‹

danger
  • Variable Not Found: Error: Cannot read property 'name' of undefined

    • Solution: Check variable names and ensure they exist in the process context before use.
  • Syntax Errors in Scripts: Error: Unexpected token

    • Solution: Validate your JavaScript syntax. Use the built-in testing interface to catch errors early.
  • Action Parameter Errors: Error: Missing required parameter

    • Solution: Ensure all required parameters for an action are correctly configured.
  • Timeout Errors: Error: Operation timed out

    • Solution: Optimize long-running scripts and actions. Consider breaking them down into smaller, more efficient operations.

10.2. Debugging Tipsโ€‹

info
  1. Use Console Logging: Add console.log() statements within your scripts to inspect variable values at different execution stages.
  2. Test Incrementally: Start with simple expressions and gradually build up to more complex logic.
  3. Check Variable Values: Use the variable finder in the interface to see what data is available in the current scope.
  4. Validate Data Types: Ensure that variables contain the data types you expect (e.g., string, number, object).
  5. Use Try-Catch Blocks: Wrap potentially failing operations in try-catch blocks to handle errors gracefully.

This comprehensive input/output system provides powerful data transformation capabilities while maintaining simplicity for common use cases. Whether you need simple variable mapping or complex business logic, the combination of scripts, expressions, and actions covers all process automation needs.