Defining Formulas

Use Primavera Cloud Expression Language to define Oracle Primavera Cloud configured field or measure formulas. Formulas are a sequence of Primavera Cloud Expression Language statements and expressions, called scripts, that programmatically determine the values of configured fields and portfolio and strategy measures. Only formulas containing well-formed Primavera Cloud Expression Language scripts are valid. A Primavera Cloud Expression Language script is well-formed if it conforms to Primavera Cloud Expression Language syntax rules. To learn more about Primavera Cloud Expression Language syntax, see the Language Reference.

The following objects support formula based measures or configured fields:

Example Primavera Cloud Expression Language Script Formula

The following example contains a formula that returns a string indicating whether project delays are likely based on a project's current Percent Complete value and the number of days until the project's Planned Finish Date.

def currentDate = new Date();
def weekFromFinish = minusDays(object.Project_planEndDate, 7);
if(object.Project_percentComplete < 95 && currentDate >= weekFromFinish){
return "Project delay likely";
} else {
return "No delays anticipated.";
}

This example showcases the basic structure of a formula defined using Primavera Cloud Expression Language. The first and second lines demonstrates variable assignment:

def currentDate = new Date();
def weekFromFinish = minusDays(object.Project_planEndDate, 7);

Variables are declared using the def keyword and are assigned values using the = operator.

Note: Primavera Cloud Expression Language variables must maintain the same type as the value they are assigned in their initial declaration and can only be reassigned values of the same type. If you attempt to reassign a declared variable a value of a different type, the script will fail to validate. For more information, see the Language Reference.

Lines three to seven of the script illustrate an conditional if statement written in Primavera Cloud Expression Language:

if(object.Project_percentComplete < 95 && currentDate >= weekFromFinish){
return "Project delay likely";
} else {
return "No delays anticipated.";
}

The conditional statement is organized in blocks indicated by opening and closing brackets. As in many other programming languages, if the expression contained in the if statement evaluates to true, the first block of the conditional is evaluated. If the expression evaluates to false, the else block is evaluated.

In general, Primavera Cloud Expression Language closely follows many of the same syntactic rules and conventions as the Java programming language. To learn more about the types, operators, and methods included in Primavera Cloud Expression Language, see the Language Reference.



Last Published Tuesday, May 21, 2024