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.
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
In the Expression builder dialog box, build an expression:
Choices
Actions
Enter the expression manually
In 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
In the header of the Expression builder dialog box,
click Browse.
In the navigation pane, click Functions to expand a
list of available function libraries.
Click a function library to expand the available functions.For example: Click DateTime to view functions connected to
calculating date and time.
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
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
In the header of the Expression builder dialog box,
click Browse.
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.
Click the selected context to expand the available properties.
Some areas, such as data pages or custom pages, might include nested data
pages.
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
Optional: To validate the correctness of the expression, test the expression:
In the header of the Expression builder dialog box, click
Test.
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
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
Click Submit.
Result: The value of the expression becomes available in the rule
form.