Flex Your APEX Implementing Oracle E-Business Suite Descriptive Flexfields in Application Express...

23
Flex Your APEX Implementing Oracle E-Business Suite Descriptive Flexfields in Application Express Shane Bentz InterVarsity Christian Fellowship/USA

Transcript of Flex Your APEX Implementing Oracle E-Business Suite Descriptive Flexfields in Application Express...

Page 1: Flex Your APEX Implementing Oracle E-Business Suite Descriptive Flexfields in Application Express Shane Bentz InterVarsity Christian Fellowship/USA.

Flex Your APEXImplementing Oracle E-Business SuiteDescriptive Flexfields in Application Express

Shane BentzInterVarsity Christian Fellowship/USA

Page 2: Flex Your APEX Implementing Oracle E-Business Suite Descriptive Flexfields in Application Express Shane Bentz InterVarsity Christian Fellowship/USA.

2

Presentation Summary

• Descriptive Flexfield Introduction• General Overview of Method

• Page Items• Application-Level Processes and Item• Database Stored Functions• Javascript Code

• Label Template Specifications• Fetch and DML Processing• Potential Future Improvements

Page 3: Flex Your APEX Implementing Oracle E-Business Suite Descriptive Flexfields in Application Express Shane Bentz InterVarsity Christian Fellowship/USA.

3

Descriptive Flexfield Introduction

• Descriptive flexfields provide a flexible way for Oracle Applications to provide customizable "spaces" within a page or pages of an application. (http://www.oracle.com/technology/tech/blaf/specs/flexfields.html)

• Generic columns (traditionally called attributes) have two general purposes:• potential future use• storing mutually exclusive data to conserve

space

Page 4: Flex Your APEX Implementing Oracle E-Business Suite Descriptive Flexfields in Application Express Shane Bentz InterVarsity Christian Fellowship/USA.

4

Descriptive Flexfield Introduction

• A dedicated governing column (traditionally named ATTRIBUTE_CATEGORY) is used to define a context-sensitive purpose for these generic columns.Example: Payment Types

(Credit Card, Cash, E-Pay, etc.)

• Each generic attribute column can be assigned a validation rule called a value set.

Page 5: Flex Your APEX Implementing Oracle E-Business Suite Descriptive Flexfields in Application Express Shane Bentz InterVarsity Christian Fellowship/USA.

5

Descriptive Flexfield Introduction

Necessary Rules (for this method):• Value sets assigned to attributes must have

a validation type of “Table”.• If an attribute column is defined as a free-

form text item, there should be no value set assigned to it.

Page 6: Flex Your APEX Implementing Oracle E-Business Suite Descriptive Flexfields in Application Express Shane Bentz InterVarsity Christian Fellowship/USA.

6

General Overview

Application Express Items and Processes:• Multiple versions (Text Field, Select List, and

Pop-Up Key LOV) of ATTRIBUTE items on your Application Express page

• Two on-demand application-level processes and one application-level item

Page 7: Flex Your APEX Implementing Oracle E-Business Suite Descriptive Flexfields in Application Express Shane Bentz InterVarsity Christian Fellowship/USA.

7

General Overview

Database and Javascript Code:• Two database functions to dynamically build

the valid list of options to be populated in select and pop-up lists

• Javascript to make everything appear magical• show/hide appropriate items• AJAX used to retrieve the validation lists• changing the label on each attribute field

• All code is provided in the presentation paper

Page 8: Flex Your APEX Implementing Oracle E-Business Suite Descriptive Flexfields in Application Express Shane Bentz InterVarsity Christian Fellowship/USA.

8

Page Items

Create the following items:• an ATTRIBUTE_CATEGORY item which

governs which attribute items are displayed.• a Text Field, Select List, and Pop-Up Key LOV

“version” of each attribute database column• hidden items for each attribute to store the

value set ID if the attribute has a table-based value set and the help text retrieved from the flexfield definition

Page 9: Flex Your APEX Implementing Oracle E-Business Suite Descriptive Flexfields in Application Express Shane Bentz InterVarsity Christian Fellowship/USA.

9

Page Items

Page items needing to be created:

Page 10: Flex Your APEX Implementing Oracle E-Business Suite Descriptive Flexfields in Application Express Shane Bentz InterVarsity Christian Fellowship/USA.

10

Page Items (Pop-Up Key LOV)

Pop-Up Key LOV items should have the following characteristic:

• a List of Values source which calls a packaged function to dynamically build the validation list. Example:begin

return ( generate_attribute_lov ( :p6_attribute1_vset_id ) );

end;

Page 11: Flex Your APEX Implementing Oracle E-Business Suite Descriptive Flexfields in Application Express Shane Bentz InterVarsity Christian Fellowship/USA.

11

Application-Level Processes

CREATE_DYNAMIC_LOV – generates XML of a list of valid options to be assigned to a select list

GET_ATTRIBUTES – generates XML to describe the needed attributes• the name of the attribute column• the attribute’s label• the value set ID of the value set for validation• flag indicating if the value set is a “long list”• help text stored in the “description” of the flexfield column• if fetching an existing record, the current value stored in

the attribute database column and its description

Page 12: Flex Your APEX Implementing Oracle E-Business Suite Descriptive Flexfields in Application Express Shane Bentz InterVarsity Christian Fellowship/USA.

12

Application-Level Item

APPL_LEVEL_VSET_ID• accessed by the CREATE_DYNAMIC_LOV on-

demand application-level process to build the list of options of a select list.

• as the AJAX code loops through each attribute item, this item temporarily stores the value set ID of the attribute currently being processed.

Page 13: Flex Your APEX Implementing Oracle E-Business Suite Descriptive Flexfields in Application Express Shane Bentz InterVarsity Christian Fellowship/USA.

13

Stored Functions

GENERATE_ATTRIBUTE_LOV• returns the SELECT statement representing the

value set associated with current attribute column to generate the list of options

• example: select description, code from master_lookup_table order by description;

GET_ATTRIBUTE_DESCRIPTION• returns the description of a code stored in an

attribute column

Page 14: Flex Your APEX Implementing Oracle E-Business Suite Descriptive Flexfields in Application Express Shane Bentz InterVarsity Christian Fellowship/USA.

14

Javascript Code

• clearAllAttributes: sets the value of all attributes to null

• hideAllAttributes: turns display of all attribute items off

• ChangeLabel*: changes the label of an item on the page*requires a change to the specified label template

Page 15: Flex Your APEX Implementing Oracle E-Business Suite Descriptive Flexfields in Application Express Shane Bentz InterVarsity Christian Fellowship/USA.

15

Javascript Code (AJAX)

• Asynchronous Javascript And XML• Application Express has built-in code which

makes implementing AJAX simple• on-demand application-level process and the

htmldb_Get Javascript function to call the on-demand application-level process

• lots of examples on the Oracle Application Express forum (http://forums.oracle.com/forums/forum.jspa?forumID=137)

Page 16: Flex Your APEX Implementing Oracle E-Business Suite Descriptive Flexfields in Application Express Shane Bentz InterVarsity Christian Fellowship/USA.

16

Javascript Code (AJAX)

• fillAttributeLOV – dynamically builds a select list• getAttributeCategoryXML – main JS function

1. uses AJAX to retrieve several pieces of information (metadata) about the necessary attribute columns

2. loops through each attribute column’s metadata to1. determine which item type to use

2. build validation lists where appropriate

3. assign the attribute-specific help text to the item

4. change the label of the item dynamically

Page 17: Flex Your APEX Implementing Oracle E-Business Suite Descriptive Flexfields in Application Express Shane Bentz InterVarsity Christian Fellowship/USA.

17

Label Template Specifications

For Javascript to dynamically change the label of an item, there are two requirements of the label template(s):

• the opening label tag must have an ID attribute for Javascript to access its contents• example: <label for=“first name” id=“fname_label”>

• the opening and closing label tags must be immediately “next to” the text of the label• example: … id=“fname_label”>First Name</label>

Page 18: Flex Your APEX Implementing Oracle E-Business Suite Descriptive Flexfields in Application Express Shane Bentz InterVarsity Christian Fellowship/USA.

18

Label Template Specifications

Two required specifications to dynamically change the label:

Page 19: Flex Your APEX Implementing Oracle E-Business Suite Descriptive Flexfields in Application Express Shane Bentz InterVarsity Christian Fellowship/USA.

19

Fetch and DML Processing

The SELECT “Before Header” process looks up the metadata description of the current record in order to know in which “version” of the attribute items to place the information.

The INSERT and UPDATE “After Submit” processes assume only the appropriate “version” of the attribute item will contain the current value.

It is important that only one “version” of the item contains the value.

Page 20: Flex Your APEX Implementing Oracle E-Business Suite Descriptive Flexfields in Application Express Shane Bentz InterVarsity Christian Fellowship/USA.

20

Fetch and DML Processing

The INSERT and UPDATE “After Submit” processes assume only the appropriate “version” of the attribute item will contain the current value.

Page 21: Flex Your APEX Implementing Oracle E-Business Suite Descriptive Flexfields in Application Express Shane Bentz InterVarsity Christian Fellowship/USA.

21

Potential Future Improvements

• Dynamically implement the “required” checkbox of an attribute column

• Addition of a “date picker” or other item types.• Dynamically create the items (using

APEX_ITEM) instead of hiding and showing “appropriate versions”.

Page 22: Flex Your APEX Implementing Oracle E-Business Suite Descriptive Flexfields in Application Express Shane Bentz InterVarsity Christian Fellowship/USA.

22

Sources and Resources

• Oracle Application Express Home Pagehttp://www.oracle.com/technology/products/database/application_express/index.html

• Oracle Application Express Forumhttp://forums.oracle.com/forums/search.jspa?forumID=137

• Oracle E-Business Suite Documentationhttp://www.oracle.com/technology/tech/blaf/specs/flexfields.html

• Javascript Tutorialhttp://www.w3schools.com/js/default.asp

Page 23: Flex Your APEX Implementing Oracle E-Business Suite Descriptive Flexfields in Application Express Shane Bentz InterVarsity Christian Fellowship/USA.

23

Contact Information

Shane BentzApplication Development Mgr.InterVarsity Christian Fellowship/USA6400 Schroeder RoadMadison, Wisconsin [email protected]

Copyright 2008