Skip to main content


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

Building expressions with the Expression Builder

Updated on May 31, 2022

Create calculations that save you time by automatically providing values in your application by authoring expressions in the Expression Builder. The Expression Builder eases the construction of expressions in your application by providing a large input area, prompting for functions, prompting for properties, and adding the ability to test your results.

For more information about the Expression Builder, see Expression Builder.

An expression is a single text element that, after evaluation at run time, usually returns a single value. Use expressions to perform operations on data, such as performing mathematical operations, comparing date and time values, manipulating text, transforming data, and converting data types. For example, you can create an expression to calculate the total salary of an employee using their base salary, a bonus that depends on their years of experience, and another bonus dependent on the number of certifications that the employee has.

  1. In Dev Studio, navigate to a place in your application where you want to build an expression.
    For example: In an activity, you can use the Expression Builder to build the function to get the current date time. You can then use the function in a Property-Set method to set case data such as SubmitDateTime.
    The following figure shows the location of the Build an expression icon in a rule form:
    Accessing the Expression Builder
    The Method Parameters section of an Activity rule form with the Build an expression icon marked.
  2. In the Expression builder dialog box, build an expression:
    ChoicesActions
    Enter the expression manuallyIn the text field, enter an expression.

    You can include combinations of constants, functions, arithmetic operators, logical operators, comparison operators, and property references or property references. For more information, see Examples of expressions.

    Tip: When you press the Period (.) key, the Expression Builder prompts a list of the fields available in the data page in which context you currently work. When you press SHIFT+2 (@), the Expression Builder prompts a list of the available functions.
    Browse for and apply a function
    1. In the header of the Expression builder dialog box, click Browse.
    2. In the navigation pane, click Functions to expand a list of available function libraries.
    3. Click a function library to expand the available functions.
      For example: Click DateTime to view functions connected to calculating date and time.
    4. Click the plus icon to add the function to your expression.
      When you add the function to the text area, the function does not include arguments.
      For example: When you add the addToDate function, the text addToDate( appears in the text area.
      Tip: Hover over a function to see a tooltip with information about each function, as shown in the following figure:
      Sample function
      Sample function with a description in a tooltip.
      Note: The Expression Builder displays only non-internal functions. To display all functions in the system, see Displaying all functions in the Expression Builder.
    5. If the function requires an argument, enter the argument value.
      For example: To add a day to the current date, after you select addToDate in the previous step, enter @CurrentDateTime()@CurrentDateTime(),"1","","","").
    Browse for and apply a property
    1. In the header of the Expression builder dialog box, click Browse.
    2. In the navigation pane, click Properties to expand a list of available properties organized by context.
      You can select properties from the following types of pages:
      Current Page
      Includes a list of properties from your current case context.
      Custom Pages
      Includes properties from custom pages defined on the Pages & Classes tab of the rule that you edit.
      Data Pages
      Includes a list of properties available from application data pages.
      Parameter Page
      Includes properties defined as parameters on the rule that you edit.
    3. Click the selected context to expand the available properties.
      Some areas, such as data pages or custom pages, might include nested data pages.
    4. Drag the property to the text field to add the property to your expression.
      Tip: Hover over the property to view additional information, such as the property name, property label, and the class that includes the property.
      For example:

      Click the Parameter Page page to display a list of parameters on the current rule, and then click the plus icon to add the parameter to your expression.

      The Expression Builder
      The Expression Builder page.
  3. Optional: To validate the correctness of the expression, test the expression:
    1. In the header of the Expression builder dialog box, click Test.
    2. If your expression includes properties or parameters, in the Test data pane, enter the values that you want to use for testing.
    Result: The Result section, which is displayed with a blue background in the following figure, includes the results of the computation. You can also test a part of the expression by selecting a fragment that you want to test, as shown in the following figure. If you test a part of the expression, the result appears in the Result of selection section.
    Testing an expression
    Expression Builder with a sample tested expression.
    If the expression includes errors, the Expression Builder displays errors in the Error section, as shown in the following figure. You can hover over the section to view the full error message.
    Error in an expression
    Expression Builder that displays an error message.
  4. Click Submit.
Result: The value of the expression becomes available in the rule 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