This chapter contains the following topics:
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.
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.
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.
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.
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.
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:
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?
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.
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.
Displays information about event relevance.
Creates an assignment or a complex expression.
Attaches an existing business function.
Attaches an existing JD Edwards EnterpriseOne system function.
Creates an If/While conditional statement.
Establishes a connection to a batch application or report.
Establishes a form interconnection.
Inserts an Else clause, which is valid only within the bounds of If and End If.
Creates a programmer-defined field.
Enables ER support for database access. Performs table input and output, data validations, and record retrieval.
On Event Rules Design, select an event.
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.
On Event Rules Design, select an event.
Click the Assignment/Expression button.
On Assignment, select the To Object that you want to receive the assigned value.
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.
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.
Select either the If or While operators.
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.
Select a logical operator comparison (is equal to, is less than, and so forth).
Select a right operand from the object list.
To assign a literal, select <Literal>.
To create complex If statements, you can select the And option or the Or option, and continue the logic.
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.
Complete the variable naming field located under the Add button.
Click one of the Scope options (Form or Event) depending on the purpose for which you created the variable.
If you selected Form Scope and you want to use a grid variable, click the Grid option.
Click the DD visual assist to browse for DD items.
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.
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:
Create a variable to hold the value of the line number. Use the data dictionary item LNID.
Initialize the variable on the Post Dialog is Initialized event.
VA frm_LineNumber_LNID = 0
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
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
On Event Rules Design, select an event.
Click the ⌊(S) button.
Select a category in the System Functions box.
Select the system function that you want to attach.
In the Available Objects list, select objects to pass to the system function.
On Event Rules Design, select an event.
Click the ⌊(B) button.
You can view a description (if one exists) for a business function by choosing Attachments from the Row menu.
Select a business function and click the Select button.
In the Available Objects list, select objects to pass to the business function.
To assign a literal to a business function parameter, select <Literal> in the Available Objects list.
Enter a single value and click the OK button.
Range and List are not valid literals to use with business function parameters.
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.
Select the Include in Transaction option to include this business function for transaction processing.
This option appears on transaction forms only.
Select the Asynchronously option to enable asynchronous processing.
Click one of these buttons to add notes:
Business Function Notes