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 TypesDirect link to 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
The Input Output tab of a task: its inputs and outputs, each with its kind (JS for a script, fx for an expression).
The Input Output tab of a task: its inputs and outputs, each with its kind (JS for a script, fx for an expression).

The Input Output tab of a step provides a centralized location for managing data transformations before and after task execution, with support for scripts, expressions, and visual action builders. The variables are edited in the Inputs & Outputs drawer (see Configuration Interface).

Each parameter is a variable of the instance: its name is the Attribute name of the parameter, and the value it gets is the value of the expression, the value returned by the script, or the result of the action.

2. Input ParametersDirect link to 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 ParametersDirect link to 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 ParametersDirect link to 4. Script Parameters

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

A script and its test: the test variables simulate the process context and the Result shows the returned value.
A script and its test: the test variables simulate the process context and the Result shows the returned value.

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. The value returned by the script (return …) is assigned to the variable. Use Test to run it with test variables before starting an instance (see Testing a Variable).

4.1. Available Variables in ScriptsDirect link to 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 ExamplesDirect link to 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 ParametersDirect link to 5. Expression Parameters

Expressions are simple text expressions.

An expression: a static value, or an expression such as ${variable}.
An expression: a static value, or an expression such as ${variable}.

The expression parameter interface enables simple string value assignments without complex scripting, ideal for static values, basic variable mapping, and straightforward text assignments: write a value, or an expression such as ${variable}.

6. Action ParametersDirect link to 6. Action Parameters

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

An action variable: the action builder, whose result is stored in the request_id variable.
An action variable: the action builder, whose result is stored in the request_id variable.

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. The result of the actions is stored in the variable. Actions have no Test button: test them by starting an instance in TEST.

6.1. Available Action CategoriesDirect link to 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 InterfaceDirect link to 7. Configuration Interface

Select a task, a user task, a send task or a sub-process in the process modeler and open the Input Output tab of its panel (gateways, events and flows do not have this tab). The tab shows two lists, each with its number of variables:

  • Input: "Evaluated when the step starts";
  • Output: "Evaluated when the step completes".

Each variable shows a badge for its kind: JS for a script, fx for an expression, a lightning bolt for an action. "Click a variable to edit or test it": a click opens the Inputs & Outputs drawer on that variable. The + button of a list ("Add or edit inputs", "Add or edit outputs"), or Add an input / Add an output when a list is empty, opens the drawer too.

The Inputs & Outputs drawer of a step: its inputs and outputs on the left, and the three kinds of variables.
The Inputs & Outputs drawer of a step: its inputs and outputs on the left, and the three kinds of variables.

The drawer shows the name of the step under its title Inputs & Outputs. Its header holds:

  • Helper : Find a variable: type a few letters to search the variables used in the interfaces and processes of the project; choosing one copies it to the clipboard;
  • the Documentation button (book icon);
  • Close (×, or Esc).

7.1. Adding ParametersDirect link to 7.1. Adding Parameters

  1. Open the step: select the task in the process modeler and open its Input Output tab.
  2. Open the drawer: click the + of the Input or Output list.
  3. Add a parameter: in the Input or Output section of the drawer, click:
    • + Script: for JavaScript code;
    • + Expression: for a value or a simple expression;
    • + Action: for visual function building.
  4. Name it: click the new variable in the list, then type its name in the Attribute name field of the toolbar on the right.
  5. Write its content in the editor, then click Save (Ctrl + S).

7.2. Parameter ManagementDirect link to 7.2. Parameter Management

7.2.1. Drag & Drop OrderingDirect link to 7.2.1. Drag & Drop Ordering

Parameters execute in order from top to bottom. Drag the handle (⠿) on the left of a variable to reorder the list:

📋 Parameter 1 (executes first)
📋 Parameter 2 (executes second)
📋 Parameter 3 (executes last)

The × of a variable removes it.

7.2.2. Editing a VariableDirect link to 7.2.2. Editing a Variable

Click a variable in the list to edit it on the right. The toolbar shows:

  • its kind (Script, Expression or Action);
  • Attribute name: the name of the variable;
  • Apply to all branches: when the instance runs parallel branches, the value is also given to the variable in every other branch;
  • Test (scripts and expressions only, Ctrl + R);
  • Save (Ctrl + S).

Under the toolbar, the editor: JavaScript ("Return the value to assign."), Expression ("A value or an expression such as ${variable}.") or the action builder.

If you changed a script or an expression and close the drawer or click another variable, SoftyFlow asks Save your changes? ("You changed this script. If you close without saving, your changes are lost."): Save or Don't save.

Save the process

Save keeps the variable in the step; the process itself is saved with Save Process in the rail of the builder. Ctrl + S in the drawer does both: it keeps the variable and saves the process. The save indicator of the builder sees a variable being added, removed or moved, but not a change to a variable (its content, Attribute name, Apply to all branches, its actions): save the process after each change (see Saving the Process).

7.2.3. Testing a VariableDirect link to 7.2.3. Testing a Variable

Scripts can be tried without starting an instance (the Test button is shown for scripts and expressions, not for actions):

  1. In the Test variables card, click Add variable and type a name and a JSON value, for example SF_initiator and {"firstName": "Jean", "lastName": "Dupont"}, or "abc", or 42. Add as many as the script needs to simulate the process context.
  2. Click Test (Ctrl + R).
  3. The Result card shows the returned value, or the error in red.

The test runs the content of the editor as JavaScript, even if it is not saved yet, in the TEST environment (SF_mode is test) and for 60 seconds at most. It really runs: the SDK calls of the script (for example an insert into a collection) really happen in TEST.

8. Best PracticesDirect link to 8. Best Practices

tip

8.1. Performance OptimizationDirect link to 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 HandlingDirect link to 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 ConventionsDirect link to 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 FeaturesDirect link to 9. Advanced Features

9.1. Dynamic Variable NamesDirect link to 9.1. Dynamic Variable Names

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

9.2. Conditional ExecutionDirect link to 9.2. Conditional Execution

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

9.3. Multi-Instance ProcessingDirect link to 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 VariablesDirect link to 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: test, uat 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.

A process started by an email also receives the subject, the sender, the text and HTML bodies and the attachments of the email: see Start a Process by Email.

10. TroubleshootingDirect link to 10. Troubleshooting

10.1. Common IssuesDirect link to 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 TipsDirect link to 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.