Skip to main content


         This documentation site is for previous versions. Visit our new documentation site for current releases.      
 

Creating a function

Updated on August 16, 2022

You can create a function to run Java code that you define. By putting your logic in a reusable function, you can reduce the amount of custom code in your application.

  1. In the Dev Studio header, click Create TechnicalFunction.

  2. On the Create form, enter values that define the context of the function.

    1. In the Add to ruleset field, select the name and unlocked version of a ruleset that stores the function.

    2. In the Library field, press the Down Arrow key and select the library to contain the function. The library must be defined in the same ruleset as the function.
  3. Define the input parameters for the function.
    1. In the Parameters section, click + Add new.

    2. In the Name field, enter a unique identifier that you can reference from your Java code.

    3. In the Java type field, enter a primitive data type, a reference data type, or a Pega data type that your library supports.

      Do not use PublicAPI or ClipboardPage, because your application manages these types internally. Use Activity or Page, respectively.

    Note: You can define two or more Function rules in one library with the same name, ruleset, and version if their input parameters have differently ordered Java types. Standard Java overloading applies.
    Caution: Review the number, order, and Java types of your input parameters, because you cannot change them after the function has been created.
  4. Click Create and open to open the Function rule form.

  5. In the Output section, in the Java data type field,either enter the return type: a primitive data type, a reference data type, or Pega data type that your library supports, or if there is no return type, enter void.
  6. In the Input parameters section, customize the function's input parameters.
    • In the Name field, you can override the name that you provided on the Create form.
    • If the Java type is String, then in the Pega type field, you can choose a data type so that additional validation is performed at run time. For other Java types, leave this field blank.
  7. Complete various fields that are used for documentation purposes.

    These values make it easier for other developers to understand your function, but they do not affect run-time behavior.

    • In the Input parameters section, enter values for the Description , Page class , and In/out fields. The Page class field is used only for ClipboardPage parameters.
    • In the Output section, enter values for the Pega type and Page class fields.
      • In the Pega type field, enter a value only if the Java data type field is set to String or a primitive data type.
      • In the Page class field, enter the class of the return value only if the Java data type field is set to ClipboardPage .
    • In the Classification section, enter values for the Usage type and Description fields.
    • To help with debugging, in the Rule type parameters section, enter one or more rule types. For more information, see Making a function traceable .
  8. Click Save.

Next: Writing Java for a function

  • Previous topic Defining URL patterns for work items
  • Next topic Function Alias rules — Completing the Create, Save As, or Specialization form

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us