Create Functions

You can create functions to define specific operations that aren’t available through built-in functions. In Process, decisions created using the Function notation return a value only when invoked from another decision.

To successfully invoke a function from another decision, the number and type of parameters in the function invocation must match those in the function definition.

The following example demonstrates a function implementation in Process. Here, the output decision invokes a function decision to calculate the seasonal discount percentage. The function decision contains the logic for regular discounts in the form of a decision table.

Description of dmn-function.png follows
Description of the illustration dmn-function.png
To create a decision with the Function notation:
  1. Add a new decision element to the model.
    1. In graph view, click Expand Expand/Collapse icon next to Decision on the diagram palette. Select Function and drag it onto the canvas. Double-click the element to edit its logic. You can also edit the function's logic from the properties pane; select the element, then select Open Properties Open Properties icon, and in the properties pane click Edit Edit icon next to the Name field.
      Click Close Close icon to return to the canvas.
    2. In list view, click Add new decision Add New Decision icon in the Decisions bar and select Function from the Create Decision window.
    A function with empty Parameters and Body fields is created, with the Expression notation selected by default for the Body field.
  2. In the Parameters field, click Add Add icon to add a new parameter. Enter a name for the parameter and select a data type for it. See Data Types.
  3. In the Body field, click Change body Change body icon to change the logical notation. Select the required notation from available options.
    Description of dmn-func-entry.png follows
    Description of the illustration dmn-func-entry.png
  4. Now, configure the logic for the selected notation. You can use input variables or built-in functions to define the logic.
  5. Click Save to save and validate changes manually. Changes you make within the decision model are also automatically saved and validated from time to time. Errors, if any, are displayed within the decision.

Note:

Because a function decision by itself doesn’t return a result, it’s not an output decision. Therefore, you can’t add function decisions to a decision service.