Function form
Completing the Java tab

  1. About 
  2. New 
  3. Parameters 
  4. Java 
  5. Alias 
  6. Imports & Exceptions 
  1. History 
  2. More... 

Enter the Java source code of the function in this tab.

Compilation Status

Field

Description

Function ready to be Compiled?

Leave this check box cleared until you finish coding the function.

At any time when this check box is cleared, another application developer can create another function with the same name. If you select this check box but your function does not work correctly, you might unintentionally prevent other developers from completing work that they could otherwise complete.

After you've tested the function and confirmed that it is ready for use, select this check box and save the rule instance.

Ordinarily, select this check box before you check in the updated function rule. A warning appears if you check in a function that is not marked as ready.

Test Function Compilation

After you have saved the instance, but before you click Generate Library, click to find any language errors.

Generate Function

Click to generate the function and the library that contains it.

Generate Library  

Click to update the library on the Pega 7 system (on the current node only).

Caution: Do not click this button until you have clicked Test Library Generation and performed other testing to confirm that your function works as intended. If you generate a library that includes compilation errors, but has the same ruleset and version as a previously generated library that compiled, the older, working CLASS files are overwritten. This can affect processing of other users of the library

Authoring

  1. Click (magnifying glass) to start your Java editor or IDE. (If you have not set up a Java editor, Pega 7 uses Windows Notepad as the editor. See How to set up a Java development environment.)
  2. Enter your Java code, which may call methods in the PublicAPI.
  3. Exit from the editor to upload the Java code into the rule form.
  4. Save the Function rule form.

Notes

Use this function to reference the activity passed in:

CallingActivity.getPage(...)

Two frequently used Java API methods are createPage() and getPage(). Consult the JavaDocs topics for the PublicAPI interface to learn more about the available methods and their parameters.

See More about Function rules for additional guidance on Java code you can use here.

Access the Parameters tab to compile the library, including this function, when you are ready to test.

Note: Use the String.equals() Java method, not the == or != operators, to compare the value of a property to a literal string or to the value of another property.

Caution: The Java code in a function rule is restricted to computations and limited types of side effects. You can't perform stateful processing, use member variables or extend classes in a function.

Up About Function rules