3 Using Event Rules Design

This chapter contains the following topics:

3.1 Understanding Event Rules Design

You can use JD Edwards EnterpriseOne Event Rules Design to create event rule (ER) logic for forms and controls on a form. For example, you want to pass data for a selected record on a find/browse form to a fix/inspect form to revise that record. You need to create a form interconnection ER and attach it to the Select button option for the Button Clicked event.

You can create event rules that perform a large variety of tasks, including:

  • Perform a mathematical calculation.

  • Pass data from a field on a form to a field on another form.

  • Count grid rows that are populated with data.

  • Interconnect two forms.

  • Hide or display a control using a system function.

  • Evaluate If/While and Else conditions.

  • Assign a value or an expression to a field.

  • Create variables or programmer-defined fields at runtime.

  • Perform a batch process upon completion of an interactive application.

  • Process table input and output, validate data, and retrieve records.

Before you create an ER, consider which control (form, button, field, grid and so on) you want to add the logic in and what event you want to add the logic for. Answer these questions to determine which event should be used:

  • Is the user initializing the form?

  • Is the user clicking a button?

  • Is the user exiting from a field?

  • Is the user changing or exiting from a row?

After you place controls on a form, you can add ERs to any of the event that the control support. Remember that a form is also a control, and you can create logic that the system automatically processes whenever a form event is fired.

You create ERs by clicking the buttons on the tool bar in JD Edwards EnterpriseOne Event Rules Design. Depending on the button that you click, a different work areas appear for creating and manipulating the ER line-by-line. Specific buttons enable you to perform these tasks:

  • Attach a business function or system function.

  • Create an If/While statement.

  • Insert an Else clause in an If statement.

  • Assign a value or expression.

  • Create a variable.

  • Create a form or report interconnection.

  • Perform table I/O.

  • Find a string in a given ER.

  • Add comments in the ER code.

  • Print the ER code.

You can cut or copy an ER and paste it in the same event, form, or application or in a different event, form, or application. You can also paste ERs into other applications, such as word processing documents. This feature is useful for documenting the project.

When you paste an ER, the system resolves objects from the source as you paste them. If an object is partially resolved, the system pastes the closest matching object from the destination ER. A comment line appears above the partially-resolved line of event rules and in the status bar to indicate that the object is partially resolved. You can set paste options to display comments before and after a block of pasted ERs. Some objects cannot be resolved in the destination ER. The system disables these lines of ER and displays a comment. For example, an EndIf statement is commented out if its associated If statement is missing.

For criteria statements, the paste operation adds whatever is necessary to maintain a clean, logical structure. For example, if you paste an If statement and no EndIf statement exists, the paste operation adds a matching EndIf statement to make the logic complete.

Use the System Function button to attach predefined system functions to events. For example, you can attach system functions to an event that perform these tasks:

  • Hide or display a control.

  • Display media objects.

You can attach an existing business function to an event. Business functions include these types of code:

  • C code that you generate manually (source language C).

  • Named Event Rules (NERs) (source language Event Rules).

You typically use business functions for these purposes:

  • Referential integrity, such as deleting secondary records when a master record is deleted, and for editing routines.

  • Large and complex calculations that might otherwise overload the runtime engine.

3.2 Understanding Event Rule Validation

When you save an application, the system automatically validates all ERs in the application. If errors occur, details on the ER event, and the control and line number being executed at the time of the error are displayed in a popup window. You can also start the validation in FDA by selectingFile, Validate Event Rules.

The error log that the system creates is stored in a file, such as b9\prod\log\p1234.log (where prod is the environment). If no errors exist, the system does not generate a log.

3.3 Understanding If and While Statements

If and While statements are conditional instructions for an ER. They evaluate conditions and dictate the flow of logic when the ER is activated.

Use the If/While button to build conditional logic into an event. When you create an If statement, the system inserts an Else clause. However, you can use the Delete button to delete the Else clause and then reinsert it using the Insert Else button. When you delete an If or While statement, the system also deletes the associated Else and Endif or Endwhile clauses, but not the lines inside of those statements.

You can drag and drop statements line-by-line to change their sequence. Resequencing ER can result in improper syntax. When you click the Save or OK button, the system verifies the syntax. If it detects syntax errors, you can either disable the ER and continue or edit the ER to eliminate the errors.

To change a statement, double click the line.

To delete a statement, choose the line of the statement, and then click the Delete button.

3.4 Understanding ER Consistency

You can check the consistency of events in JD Edwards EnterpriseOne Event Rule Designer. Events can be either relevant or not relevant. A relevant event is one that is valid and that can be executed by the associated control. A not relevant event is one that is not executed by the associated control because the properties of that control do not create the conditions that cause the events to execute. You can change a not relevant event to a relevant event by updating the properties of the control.

3.5 Understanding ER Variables

An ER variable is a variable that you can use within the ER. You must assign a DD item to an ER variable. The DD item defines the type and default behavior of the variable.

Use ER variables instead of hidden fields. ER variables use fewer system resources at runtime.

After you add an ER variable, you cannot modify it. Instead, you must delete it and create another one.

Each ER variable is available within a scope. The scope of an ER variable determines how you can use it. Different scope options are available for interactive and batch applications. For example, you can:

  • Reference a report variable anywhere in the report.

  • Reference an ER variable only within the event in which it was created.

After you create an ER variable, it appears in the available objects list in JD Edwards EnterpriseOne Event Rules Designer where you added it. Use the ER variable in ERs just as you would use any available object in the list. If you create an event level variable and do not use it in ERs, FDA automatically deletes it.

The system automatically assigns to each variable one of these prefixes, based on the specified scope:

  • frm_ (Form)

  • evt_ (Event)

  • grd_ (Grid)

  • rpt_ (Report)

  • sec_ (Section)

3.6 Prerequisites

Before you complete the tasks in this section:

  • Create an application with one or more forms.

  • Understand the difference between database items and data dictionary (DD) items.

  • Understand the relationship between controls, events, and ER.

  • Determine the purpose of each form used in the application.

  • Answer these questions:

    • What logic is required?

    • For which control are you creating logic?

    • For which event will the logic occur?

    • Which runtime structures are affected?

3.7 Working with Event Rules Design

This section provides overviews of assignments and event rules design tool bar buttons, and discusses how to:

  • Display event information.

  • Assign a value.

  • Create an If or a While statement.

  • Create an ER variable.

  • Attach a system function to an event.

  • Attach a business function to an event.

3.7.1 Understanding Assignments

Use an assignment to assign a field with a fixed value or a mathematical expression. For example, you can create an assignment that inserts a default value when the user leaves the field. You can also use an assignment to calculate a value

When you create an expression, calculate only the data items that are of the exact same numerical scale or data type. For example, do not calculate different currencies or decimal figures that represent different decimal values because the result of these calculations might compromise data integrity.

3.7.2 Understanding Event Rules Design Tool Bar Buttons

The Event Rules Design form displays these tool bar buttons for generating different types of statements:

  • Event Information

    Displays information about event relevance.

  • Assignment

    Creates an assignment or a complex expression.

  • Business Function

    Attaches an existing business function.

  • System Function

    Attaches an existing JD Edwards EnterpriseOne system function.

  • If/While

    Creates an If/While conditional statement.

  • Report Interconnect

    Establishes a connection to a batch application or report.

  • Form Interconnect

    Establishes a form interconnection.

  • Else

    Inserts an Else clause, which is valid only within the bounds of If and End If.

  • Variable

    Creates a programmer-defined field.

  • Table I/O

    Enables ER support for database access. Performs table input and output, data validations, and record retrieval.

3.7.3 Displaying Event Information

To display information about the relevance of an event:

  1. On Event Rules Design, select an event.

  2. Click the Event Information button.

A not relevant event is displayed in dimmed italic text in the Event combo box. A message box appears that displays any information known to the system about why a not relevant event is not relevant.

3.7.4 Assigning a Value

To assign a value:

  1. On Event Rules Design, select an event.

  2. Click the Assignment/Expression button.

  3. On Assignment, select the To Object that you want to receive the assigned value.

  4. Use one of these methods to determine the From/Object Literal value:

    • Select a From Object in the right-hand column to create a simple statement: [left-hand column] = [right-hand column].

    • Type a literal expression (number, text, and so on) in the text entry box to assign a literal statement: [left-hand column] = [literal].

    • Press the ⌊(X) button to create a complex expression or advanced mathematical function using Expression Manager.

3.7.5 Creating an If or a While Statement

To create an If or a While statement:

  1. On Event Rules Design, select an event in the Event Rules Design window and click the If/While button.

    Each cell in the Criteria Design grid represents a component of the criteria. When you select a cell, a list of valid options appears.

  2. Select either the If or While operators.

  3. Select a left operand from the list of available data items.

    Right-click to sort the available data items by name or object type. If only one type exists, the sort options are unavailable. The system groups the available data items by a variety of object types.

  4. Select a logical operator comparison (is equal to, is less than, and so forth).

  5. Select a right operand from the object list.

  6. To assign a literal, select <Literal>.

  7. To create complex If statements, you can select the And option or the Or option, and continue the logic.

3.7.6 Creating an ER Variable

To create an ER variable:

  1. On Event Rules Design, click the Variables button.

    The Variables form displays different scope options, depending on whether you are working with an interactive application, batch application, or NER.

  2. Complete the variable naming field located under the Add button.

  3. Click one of the Scope options (Form or Event) depending on the purpose for which you created the variable.

  4. If you selected Form Scope and you want to use a grid variable, click the Grid option.

  5. Click the DD visual assist to browse for DD items.

  6. Select the DD item to which the variable is associated and click the Add button.

    The system automatically assigns a prefix to the variable, based on the type of scope that you choose. Using Event Rule Variables for Automatic Line Numbering

You can use event rules to create automatic line numbering in form grids. Automatic line numbering means that each line in the grid will have a unique number and the lines will increment automatically as grid lines are added.

To create automatic line numbering event rules:

  1. Create a variable to hold the value of the line number. Use the data dictionary item LNID.

    VA frm_LineNumber_LNID
  2. Initialize the variable on the Post Dialog is Initialized event.

    VA frm_LineNumber_LNID = 0
  3. On the Grid Record is Fetched event, number the lines as each line is pulled from the database.

    If BC LineNumber > VA frm_LineNumber_LNID
    VA frm_LineNumber_LNID = BC LineNumber
    End If
  4. On the Add Last Entry Row to Grid event, increment the line number and assign the new value to the next available line.

    VA frm_LineNumber_LNID = VA frm_LineNumber_LNID + 1
    GC LineNumber = VA frm_LineNumber_LNID

3.7.7 Attaching a System Function to an Event

To attach a system function to an event:

  1. On Event Rules Design, select an event.

  2. Click the ⌊(S) button.

  3. Select a category in the System Functions box.

  4. Select the system function that you want to attach.

  5. In the Available Objects list, select objects to pass to the system function.

3.7.8 Attaching a Business Function to an Event

To attach a business function to an event:

  1. On Event Rules Design, select an event.

  2. Click the ⌊(B) button.

    You can view a description (if one exists) for a business function by choosing Attachments from the Row menu.

  3. Select a business function and click the Select button.

  4. In the Available Objects list, select objects to pass to the business function.

  5. To assign a literal to a business function parameter, select <Literal> in the Available Objects list.

  6. Enter a single value and click the OK button.

    Range and List are not valid literals to use with business function parameters.

  7. Indicate the direction of data flow between Value and Data Items, and click the OK button.

    As you click the direction arrow, it toggles through these four options:

    • Data flows from the source to the target (right-pointing arrow).

    • Data flows from the target to the source (left-pointing arrow).

    • Data flows from the source to the target, and upon exiting the target, data flows back to the source (bi-directional arrow).

    • No data flow (slashed circle).

      If the direction of the items is hard-coded in the data structure for a business function (such as when the parameters are predetermined to be input, output, or bidirectional), then this predetermined direction appears here. You must complete the required items that appear in red. The status bar indicates the state of the flow to the target.

  8. Select the Include in Transaction option to include this business function for transaction processing.

    This option appears on transaction forms only.

  9. Select the Asynchronously option to enable asynchronous processing.

  10. Click one of these buttons to add notes:

    • Business Function Notes

    • Structure Notes

    • Parameter Notes