Skip to content

Martini Workflows Invoke Function Node

Overview

Martini includes built-in functions that let you parse data, process information, or use external dependencies—enhancing the capabilities of your workflows without writing boilerplate code. Additionally, you can create and invoke your own custom Groovy class functions for enterprise-specific logic. The Invoke Function Node lets you call both types of functions directly from your workflow.

Two Types of Functions Available:

  • Martini Functions: Core functions provided by Martini for common tasks like string manipulation, date calculations, data validation, and format conversions. To see a list of all available Martini functions and their usage, see Martini Functions
  • Groovy Class Functions: Your own custom functions that you create for specific business logic and enterprise requirements. Learn how to create them at Creating Groovy Methods

What You Will Learn

  • How to add Invoke Function nodes to your workflow (drag and drop)
  • How to connect your workflow data to function inputs and outputs using the Data Mapper Panel
  • How to troubleshoot common issues

When to Use Invoke Function Nodes

Consider using a function node whenever you need to:

  • Transform or manipulate data - Instead of writing a new script, service or workflow, check if there's a built-in function that does what you need
  • Perform common programming tasks - Things like string manipulation, date calculations, data validation, or format conversions
  • Avoid reinventing the wheel - Before building custom logic, browse the Martini Functions library to see what's already available
  • Ensure reliable, tested code - Built-in functions are thoroughly tested and optimized
  • Save development time - Functions provide ready-made solutions for routine operations

Prerequisites

Before you start:

Helpful to know (but we'll explain as we go):

Adding Invoke Function Nodes to Workflows

You can add both types of functions to your workflow using similar methods. The process differs slightly depending on where the functions are located:

Adding Martini Functions (Core Functions)

  1. Open your Martini package in the Navigator and double-click your workflow to open the Workflow Designer.
  2. In the sidebar on the left, open the Functions view by clicking the icon. From here, you may search for a specific Martini function you need or look from the list of available Martini functions that are grouped by categories.
  3. Once you choose your desired Martini function, drag it onto the Workflow Designer canvas.
  4. The Martini function becomes an Invoke Function Node.
  5. Connect the Invoke Function Node to Trigger nodes and other nodes using workflow edges.

Adding Groovy Class Functions (Your Custom Functions)

  1. Open your Martini package in the Navigator and double-click your workflow to open the Workflow Designer.
  2. In the Navigator, locate your Groovy class file indicated by the icon.
  3. Expand the Groovy class to see your declared functions indicated by the icon.
  4. Drag your desired Groovy class function onto the Workflow Designer canvas.
  5. The Groovy class function becomes an Invoke Function Node.
  6. Connect the Invoke Function Node to Trigger nodes and other nodes using workflow edges.

Quick Add: Invoke Function Node via Edge

To quickly add an Invoke Function Node using the content assist popup:

  1. Drag an edge from any node and drop it onto a blank area of the Workflow Designer canvas.
  2. In the popup, type to search for the desired function name (works for both Martini functions and Groovy class functions).

    Tip: When you use the content assist popup, you can search for workflows, services, nodes, Martini functions, and Groovy class functions. Look for functions in the results—they have a icon before their name.

  3. Double-click the function in the results or press Enter.
  4. The Invoke Function Node is added and automatically connected by the edge.

Expected result: An Invoke Function Node appears in your workflow, ready for property mapping and transformation in the Invoke Function Mapper Panel.

Using the Invoke Function Data Mapper Panel

The Invoke Function Data Mapper Panel uses Martini's standard Data Mapper Panel. Before proceeding, we highly recommend familiarizing yourself with the Data Mapping Guide to understand the fundamental concepts of property mapping, connections, and data transformation in Martini.

The panel is a powerful visual interface for connecting and transforming data between your workflow and the functions you invoke. It allows you to see all available properties, map workflow inputs to function inputs, and route function outputs back into your workflow. You can also declare new properties and set custom expressions.

What makes it specific to Invoke Function Nodes:

  • Input Panel (left): Map workflow properties to function inputs.
  • Output Panel (right): Map function outputs to workflow properties.

For complete details on using the Data Mapper Panel, including creating map lines, set expressions, and property management, see the Data Mapping Guide.

Getting Started with the Invoke Function Data Mapper

  1. Click the expand icon on your Invoke Function Node to open the Data Mapper Panel.
  2. The panel appears in the lower half of the Workflow Designer.

Expected result: The Data Mapper Panel opens, showing your current workflow properties and the function's input/output properties.

Input Panel

When you open the Data Mapper Panel on an Invoke Function Node, the Input Panel appears on the left side and has a specific layout for mapping your workflow properties to the invoked function's properties.

Here's what the Input Panel looks like for Invoke Function Nodes:

1
2
3
4
| Workflow Properties      | Mapping Lines |     Function Input Properties     |
|--------------------------|---------------|-----------------------------------|
|        [input1]          |   ------->    |      [functionIn1]                |
|        [input2]          |   ------->    |      [functionIn2]                |
  • Workflow Properties (left): These are the available properties from your workflow, including both workflow inputs and any properties created or updated by the current and previous nodes. You use these as sources to pass data into the function.
  • Mapping Lines (middle): Visual connectors showing how data flows.
  • Function Input Properties (right): These are the fields that your function expects as input. Any workflow property you map here will be passed into the function when the workflow runs.

Output Panel Layout

When you open the Data Mapper Panel on an Invoke Function Node, the Output Panel appears on the right side and shows how data flows from the invoked function's output back to your current workflow.

1
2
3
4
|     Function Output Properties     | Mapping Lines | Workflow Current/Output Properties |
|------------------------------------|---------------|------------------------------------|
|      [functionOut1]                |   ------->    |         [workflowOut1]             |
|      [functionOut2]                |   ------->    |         [workflowOut2]             |
  • Function Output Properties (left): Source properties produced by the function.
  • Mapping Lines (middle): Visual connectors showing how data flows.
  • Workflow Current/Output Properties (right): Target properties in your workflow, including workflow outputs and any properties created or updated by the current and previous nodes.

Mapping Properties

For complete details on key terms (Input Panel, Output Panel, Map Lines, Set Expression), configuration controls (Declare Property, Delete, Collapse All, etc.), property management, and property creation methods when mapping data between your workflows, see the Data Mapping Guide.

Map Lines

Map lines work exactly as described in the Data Mapping Guide. For Invoke Function Nodes specifically: For Invoke Function Nodes specifically:

  1. Open the Data Mapper Panel on your Invoke Function Node
  2. Create connections between your workflows:
  3. For inputs: Create map lines from your current workflow properties to the invoked function's input properties (in the Input Panel)
  4. For outputs: Create map lines from the invoked function's output properties back to your current workflow properties (in the Output Panel)

For complete map line creation methods, including drag-and-drop and right-click shortcuts, see Working with Map Lines.

Set Expressions - Custom Data Transformation

Invoke Function Nodes support the full range of set expressions described in Assigning Dynamic Values to Properties with Set Expressions. This allows you to:

  • Transform data moving between your workflow and invoked function with custom calculations
  • Set static configuration values
  • Format data for subsequent workflow nodes

For complete details on creating and using set expressions, including examples and best practices, see the Set Expressions section in the Data Mapping Guide.

How Data Flows Through Functions

Here's what happens step-by-step when your workflow runs:

Step 1: Your Workflow Reaches the Function Node

Your workflow processes data and reaches the Invoke Function Node.

Step 2: Input Data Gets Mapped

Data from your workflow gets copied to the function's input parameters based on your data mappings.

Step 3: Function Executes

The function runs with your input data and produces results.

Step 4: Output Data Gets Mapped Back

Function results get copied back to your workflow properties based on your output data mappings.

Step 5: Workflow Continues

Your workflow continues with the function results available for the next steps.

Real Example: Capitalizing Customer Names

This walkthrough shows you exactly how to use a function node to clean up customer names in a registration workflow.

The Problem

Your registration workflow receives customer names in various formats ("john smith", "MARY JONES", "bob wilson"), and you need them consistently capitalized ("John Smith", "Mary Jones", "Bob Wilson").

Step-by-Step Solution

Starting point: Your workflow has a customerName input property.

Step 1: Add the Function

  1. Open the Functions panel in your Workflow Designer
  2. Search for String.capitalize
  3. Drag it onto your Workflow Designer canvas
  4. Connect it between your Trigger Node and next nodes

Step 2: Connect Input Data

  1. Click the expand icon on the String.capitalize function node
  2. In the Input Panel, drag from customerName to str:
1
2
Your Workflow Properties  →  Function Inputs
      customerName        →      str

Step 3: Connect Output Data

  1. In the Output Panel, drag from output to create formattedName:
1
2
Function Outputs  →  Your Workflow Properties
     output       →      formattedName

Step 4: Test the Result {#capitalize-example-result}

Input data:

1
customerName = "john smith"

After function runs:

1
formattedName = "John Smith"

Success! Your workflow now automatically formats customer names consistently.

Want to see all available functions? Check out Martini Functions for a complete list with examples.

Troubleshooting

Problem Detection Cause Fix
Invoke Function Node not invoked Workflow does not produce expected output There are no edges connecting the Invoke Function Node to the rest of the workflow, Mapping missing or incorrect Check Mapper Panel for correct property mapping
Property not available Property missing in Mapper Panel Property not declared or mapped Declare property in Output Panel and map correctly

Helpful Resources