Creating Rules with Actions and Conditions

To create rules with actions and conditions, use the Actions and Conditions (TL_ACTION and TL_CONDITIONS) components.

When you define actions and conditions in Time and Labor, you define them independently of one another, which enables you to reuse the same actions or conditions in more than one rule without having to define them again. Using actions and conditions does not require a mastery of SQL.

This section discusses how to create rules with actions and conditions.

Page Name

Definition Name

Usage

Action Header Page

TL_ACTION_PNL1

Define or view general information for a SQL action. Specify the action to perform (delete, insert, or update) and identify the target record (table) to perform the action on. If action type is insert (from another table), specify the source record (table).

Action Detail Page

TL_ACTION_PNL2

Create the text of your SQL action.

Conditions Page

TL_CONDITION2_PNL

Define or view general information for a SQL condition and create the text of a SQL condition.

Use the Action Header page (TL_ACTION_PNL1) to define or view general information for a SQL action.

Specify the action to perform (delete, insert, or update) and identify the target record (table) to perform the action on. If action type is insert (from another table), specify the source record (table).

Image: Action Header page

This example illustrates the fields and controls on the Action Header page. You can find definitions for the fields and controls later on this page.

Action Header page

Some fields on the Action Header page always appear; others appear only in connection with the action type of Insert. These elements always appear:

Field or Control

Definition

Save As ...

Select to duplicate an action by giving it a different name, or create an action that is similar to an existing action or a PeopleSoft-delivered action. This function replaces the Copy Actions page from previous releases of PeopleSoft Time and Labor.

Important! When you use the Save As... button to create the copy, the system saves the source object with any modifications prior to selecting the Save As ... button. You should always create the copy first, and then make changes to the object.

Note: You cannot modify individual actions or conditions after they are part of a rule and the system is in production (that is, after Production Environment is selected on the Installation Options page).

Action Type

Specify the SQL action to perform. Valid values are:

  • Update: Select to change an existing row of data. Identify a table to update in the Target Record (Table) Name field. In addition, define the type and source of the data to use to update the target record on the Action Details pages.

  • Delete: Select to delete the data in a table. Identify a table to delete in the Target Record (Table) Name field.

  • Insert: Select to insert a row of data into a table. Identify a table into which to insert data in the Target Record (Table) Name field, and the source of the data in the Source Record (Table) Name field. If the action type is Insert, further define the data to be inserted into the target record using the Action Details pages.

Core Component

This field is display-only and system-maintained. Several SQL objects are delivered with the Time and Labor application. These objects are used in templates. If the object you are viewing was created by the PeopleSoft system, this check box is selected; if you created this object, this check box is cleared. You cannot modify or save this object, but you can copy it and modify the copy.

Target Record (Table) Name

Enter the record (table) you want to delete, update, or perform the insert on. The records contained in the prompt table are those made available for deletion, insertion, or updating on the Working Tables page.

Explanation

Use this expression text box to explain the action you are defining.

These fields appear only if you select an action type of Insert:

Field or Control

Definition

Source Record (Table) Name

The source record (table) from which you are taking data to perform the insert.

Insert Source Indicator

The field that enables you to specify the exact source of the data used to perform the Insert. Valid values are:

From Another Table: If you select this value, the Source Record (Table) Name field is available. Enter the source record from which you are taking data to perform the insert. Go to the Action Details pages to specify the source of the data to enter into the Target Record (Table) fields.

From a List of Values: If you select this value, the Source Record (Table) Name field is unavailable. Enter the target record into which you are inserting the list of values. To define the exact values to insert in each field contained in this record, go to the Action Details pages.

Note: Click the links at the bottom of this page to access other pages in this component.

Use the Action Detail page (TL_ACTION_PNL2) to create the text of your SQL action.

Image: Action Detail page

This example illustrates the fields and controls on the Action Detail page. You can find definitions for the fields and controls later on this page.

Action Detail page

If the action type on the Action Header page is Update or Insert, provide additional information about the fields in the target record (table) on which you are performing the action. For example, answer these questions: what fields are you updating or inserting data into and what are the sources (and types) of data that you are using to perform the insert or update?

The specific information to enter depends on the type of action specified on the Action Header page and the value entered in the Insert Source Indicator field.

Enter the action details on the Action Details 1 and Action Details 2 tabbed grids. These grids work in combination; when you select a value on the Action Details 1 grid, related fields become available on the Action Details 2 grid.

Note: The Action Detail page is not available if your action type is Delete. Because you are deleting the contents of an entire record (table), do not enter field-level information on the Action Detail page.

Field or Control

Definition

Field Name
  • If the action type is Update, use this field to identify the fields in the target record (table) to update. Define the type and source of the data to use to perform the update in the Source Field Indicator field.

  • If the action type is Insert - From a List of Values, the Field Name column displays the fields belonging to the target record (table) identified on the Action Header page. These are the fields for which you are creating a new row. By default, if you are inserting from a list of values, the Source Field Indicator field is set to Constant. Enter the constant values to use for the insert action in the Constant field on the Action Details 2 page.

    You can override the default and select one of these options:

    Expression

    Meta-SQL

    RuleTmplt

    State Var

    Note: RecField is not available when you insert from a list of values.

  • If the action type is Insert - From Another Table, the Field Name column displays the fields belonging to the target record (table) identified on the Action Header page. These are the fields for which you are creating a new row. By default, if you are inserting From Another Table, the Source Field Indicator is set to RecField. Enter the RecFields that are the source of the insert in the SRC (source) FieldName column of the Action Details 2 page. You can override the default and select one of these options:

    Constant

    Expression

    Meta-SQL

    State Var

Source Field Indicator
  • If the action type is Update:

    For each field in the target record (table) that you update, identify the type and source of the data to use to perform the update in the Source Field Indicator field. Valid values are:

    • Constant: If the source field indicator is Constant, the Constant field on the Action Detail 2 page is available. Enter the constants to insert in the Target Record (Table) fields.

    • Expression Text: If the source field indicator is Expression, the Expression Text field on the Action Detail 2 page is available. Create an expression text. For example, this could be a subquery that updates a row of data in the target record (table).

    • Meta-SQL: If the source field indicator is Meta-SQL, the Meta-SQL field on the Action Detail 2 page is available. Enter the meta-SQL to use to update a field or a row of data in the target record (table).

    • RecField: If the source field indicator is RecField, the SRC Field Name field on the Action Detail 2 page is available. Enter another field from the target record (table) to use as the source of the update (the source and target records are always the same when the action is Update). For example, if you use one of the Intermediate Payable Time tables as both the source and target of the update, you could set the ORIG_TRC to TRC in a rule that changes the TRC.

    • State Variable: If the source field indicator is State Var, the State Variable field on the Action Detail 2 page is available. Enter the state variable from any Time and Labor state record to use as the source of the update.

  • If the action type is Insert - From a List of Values:

    By default, if you insert from a list of values, the Source Field Indicator field is set to Constant. Enter the constant values to use for the insert action in the Constant field on the Action Detail 2 page. You can override the default and select one of these options:

    • Expression Text: If the source field indicator is Expression, the Expression Text field on the Action Detail 2 page is available. Create an expression text. For example, this could be a subquery that generates data for the insert into the target record (table).

    • Meta-SQL: If the source field indicator is Meta SQL, the Meta-SQL field on the Action Detail 2 page is available. Enter the meta-SQL to use as the source of the insert into the target record (table).

    • State Variable: If the source field indicator is State Var, the State Variable field on the Action Detail 2 page is available. Enter the state variable from any Time and Labor state record to use as the source of the insert.

      Note: RecField is not available when you insert from a list of values.

  • If the action type is Insert - From Another Table:

    By default, if you insert from another table, the Source Field Indicator field is set to RecField. Enter the RecFields that are the source of the insert in the SRC (source) FieldName column on the Action Detail 2 page. You can override the default and select one of these options:

    • Constant: If the source field indicator is Constant, the Constant field on the Action Detail 2 page is available. Enter the constants to insert in the Target Record (Table) fields.

    • Expression Text: If the source field indicator is Expression, the Expression Text field on the Action Detail 2 page is available. Create an expression text. For example, this could be a subquery that generates data for the insert.

    • Meta-SQL: If the source field indicator is Meta-SQL, the Meta-SQL field on the Action Detail 2 page is available. Enter the meta-SQL to insert data into the target record (table).

    • State Variable: If the source field indicator is State Var, the State Variable field on the Action Detail 2 page is available. Enter the state variable from any Time and Labor state record to use as the source of the insert into the target record (table).

Action Detail

Field or Control

Definition

Field Name

This column contains the fields in the target record (table) that you are updating or performing the insert action on.

  • If the action is Update, this column displays the same fields you entered in the Field Name column on the Action Detail 1 page. These fields belong to the target record (table) that you have chosen to update.

  • If the action is Insert - From a List of Values, this column displays the Target Record (Table) fields on which you are performing the insert.

  • If the action is Insert - From Another Table, this column displays the Target Record (Table) fields on which you are performing the insert.

This page displays additional fields, depending on the source field indicator selected on the Action Detail 1 page:

Field or Control

Definition

Constant

Displays if the source field indicator is Constant.

Enter the constant to use for the update or insert.

i_7e99_htlr7f3f

Displays if the source field indicator is Expression.

Click the button to access the Expression Text field.

Meta-SQL

Displays if the source field indicator is Meta-SQL.

Enter the meta-SQL to use for the insert or update action.

i_7e98_htlr7f3d

Displays if the source field indicator is Meta-SQL.

Click the button to set parameters within the meta-SQL.

SRC FieldName (source fieldname)

The system displays this field if the source field indicator is Rec Field (Record.Field) and the action type is Update or Insert - From Another Record.

  • If the action type is Update, enter the fields in the source record (table) that contain the data to perform the update.

    Note: In the case of an update, the source record (table) is identical to the target record (table) identified on the Action Header page.

  • If the action type is Insert - From Another Record, enter the fields belonging to the source record (table) that you want to use as the source of the insert. The source record (table) is the source record you identified on the Action Header page.

State Variable

The system displays this field if the source field indicator is State Var(state variable).

Enter the state variable from any Time and Labor state record to use as the source of the update or insert.

Use the Conditions page (TL_CONDITION2_PNL) to define or view general information for a SQL condition and create the text of a SQL condition.

Image: Conditions page

This example illustrates the fields and controls on the Conditions page. You can find definitions for the fields and controls later on this page.

Conditions page

Note: Template-built rules are not effective-dated; however, they are associated with an effective-dated rule program.

To define a condition on the Conditions page, specify the exact relationship that must occur between the elements before an action occurs. The action occurs only if the defined relationship is true. For example, you can specify that an action occurs only if a field equals a certain value or you can specify that an action occurs only if a field value is greater than another defined value. You specify the kinds of elements to compare (for example, a field value to a constant) in the Left Side and Right Side group boxes in the Expression Type fields. You define the precise relationship to occur between these elements (before an action can occur) in the Operator field.

The Conditions page contains several fields that appear permanently, and others that display or hide depending on the left and right condition expression type. The following fields always appear:

Field or Control

Definition

Save As ...

Select to duplicate a condition by giving it a different name, or create a condition that is similar to an existing condition or a PeopleSoft-delivered condition. This function replaces the Copy Conditions page from previous releases of PeopleSoft Time and Labor.

Important! When you use the Save As... button to create the copy, the system saves the source object with any modifications prior to selecting the Save As ... button. You should always create the copy first, and then make changes to the object.

Note: You cannot alter individual actions or conditions after they are part of a rule and the system is in production (that is, after Production Environment is selected on the Installation Options page).

Core Component

This field is display-only and system-maintained. Time and Labor delivers many SQL objects that are used in templates. If the object you are viewing was created by PeopleSoft, this check box is selected; if you created this object, this check box is cleared. You cannot modify or save this object, but you can copy it and modify the copy.

Expression Type

Specify the types of elements to compare in the Left Side and Right Side group boxes to define the condition. Establish the correct relationship between these elements using the Operators field. Valid values are: Constant, Expression, Meta-SQL, Record Field, Rule Tmplate and State Variable.

Operator

This field always appears, regardless of the left side or right side expression type. Use the operator to define the relationship between the elements on the left and the right halves of the page. Select one of these values:

< (less than)

<= (less than or equal to)

<> (Less than or greater than

= (equal to)

> (greater than)

>= (greater than or equal to)

EXISTS

IN

NOT EXISTS

NOT IN

Explanation

Use this expression text box to explain the condition you are defining.

Depending on the values in the Expression Type fields, these additional fields appear:

Expression Type

Additional Fields

Constant

The Left Constant or Right Constant field appears. Enter a constant to define the condition.

Expression Text

The Left Condition Expr Type (left condition expression type) or Right Condition Expr Type (right condition expression type) field appears. Enter an expression to define your condition. The expression text can be any length.

Meta-SQL

The Left Meta-SQL or Right Meta-SQL field appears. Enter the appropriate meta-SQL to define the condition.

Record Field

If the left or right condition expression type is RecField, these fields appear:

  • Left Record (Table) Name or Right Record (Table) Name. Enter the left or right record that you will use to define the condition.

  • Left Aggr Func (left aggregate function) or Right Aggr Func (right aggregate function). The valid values for this field are: Avg (average), Count, Count (*),Max (maximum), Min (minimum), Sum.

  • Left Field Name or Right Field Name. Enter the name of the field belonging to the left or right record (table) name.

State Variable

The Left State Variable or Right State Variable field appears. Enter the state variable to use to define the condition.