Form Personalization Advanced Concepts
1-1
Copyright © 2004, Oracle. All rights reserved.
Objectives After completing this module, you should be able to do the following: Work with GLOBAL variables Understand Oracle Forms Query-by-Example (QBE) mode Create Special menu entries ‘Zoom’ to other functions
1-2
Copyright © 2004, Oracle. All rights reserved.
Related Course Material The viewlet Oracle Applications Form Personalization Demonstration – Advanced Concepts shows many of the concepts included in this module.
1-3
Copyright © 2004, Oracle. All rights reserved.
Agenda Global Variables Query-by-Example (QBE) mode Special menu entries ‘Zooming’
1-4
Copyright © 2004, Oracle. All rights reserved.
WARNING! Form Personalizations allows you to fundamentally alter the behavior of the product that Oracle ships, and access any and all data. Therefore, This feature should only be made available to trusted users. Avoid building Personalizations on a production system. – Form Personalizations should first be entered and thoroughly QA’ed on a test system before they are loaded to a production system 1-5
Copyright © 2004, Oracle. All rights reserved.
Global Variables GLOBAL variables are dynamically created at runtime They can hold up to 255 bytes They are visible across all forms that are currently running They are very useful for Form Personalizations! – Allow you to establish a value once then reuse it – Allow you to pass information between forms
1-6
Copyright © 2004, Oracle. All rights reserved.
Global Variables, continued 2 Properties affect them: VALUE: –
Creates it if it does not exist – Always sets the value INITIAL VALUE: – Creates it if it does not exist, setting it to null – Only sets the value if it is currently null
1-7
Copyright © 2004, Oracle. All rights reserved.
Global Variables, continued Name any you create starting with ‘XX’ –
Prevent collisions with global variables that base product code creates
In Conditions and evaluated strings, refer to them with :global. – –
Example: ='Your password must have at least '||: global.xx_password_length||' characters.' References will produce an error if the variable does not exist yet Make sure they exist by first setting the INITIAL VALUE property in a prior action or rule
Remember, they are shared across all forms 1-8
Copyright © 2004, Oracle. All rights reserved.
Global Variables, continued
Creates the global variable :global.xx_password_failures if it did not already exist Sets its value to :global.xx_password_failures Because the example is self_referencing, a prior Action needs to have created it! 1-9
Copyright © 2004, Oracle. All rights reserved.
QBE Mode QBE is a power-user mechanism to locate records, instead of Find Windows Normally invoked by selecting View > Query By Example > Enter from the pulldown menu The builtin DO_KEY with argument ENTER_QUERY will invoke this mode, for the current block It is a ‘mode’ –
–
1-10
Things operate differently, or are suspended, until you exit this mode by Running a query or selecting Cancel Specifically, any actions after invoking the mode will not be executed until the mode is exited Copyright © 2004, Oracle. All rights reserved.
QBE Mode, continued Trigger Events can fire in QBE mode, or not – – – –
1-11
Set ‘Fire in Enter-Query Mode’ as desired This will cause the Rule to execute in both QBE and ‘normal’ mode It is very, very, very rare that you would want your rules to fire in this mode! Later we’ll discuss one example where this could be used.
Copyright © 2004, Oracle. All rights reserved.
Special Menus Embedded in every menu are 45 entries you can activate
Each has the name SPECIAL# – – –
SPECIAL1 though 15: under ‘Tools’ SPECIAL16 though 30: under ‘Reports’ SPECIAL31 though 45: under ‘Actions’
Must be activated in a Rule based on the WHEN-NEW-FORM-INSTANCE event 1-12
Copyright © 2004, Oracle. All rights reserved.
Special menus, continued
Menu Entry: which entry you want to activate Menu Label: the text for the menu entry Render Line before menu: will draw a separator line above the menu entry Enabled In Block(s): the blocks for which the menu entry should be enabled. –
Leave blank to enable for all blocks.
Icon Name: the name of an optional .ico file, which will render in the toolbar 1-13
Copyright © 2004, Oracle. All rights reserved.
Special menus, continued
This action:
Activates the Tools menu and creates the menu entry, for all blocks of the form: 1-14
Copyright © 2004, Oracle. All rights reserved.
Special menus, continued But ‘Special’ simply activates the menu entry –
–
At runtime, if the user selects it, it emits an event name that matches the menu entry name For example, if you activate SPECIAL1, when the user selects it the event ‘SPECIAL1’ will be sent You create a second rule that triggers off that event and does what you want
WARNING –
1-15
Base product code uses these menu entries too. Select an entry they do not use The Menu Entry list shows the current label if there is one; no label is an indication it is currently unused Copyright © 2004, Oracle. All rights reserved.
Zooming One of the most commonly requested enhancements: – The ability to open a function, passing context from the current function For example, from the Purchase Orders form, open the Vendors form, and pass the vendor on the current PO to query its details Special+Globals+QBE let’s you define these yourself!
1-16
Copyright © 2004, Oracle. All rights reserved.
Zooming: One Strategy
Activate a Special menu In response to that menu (when selected by the user), – Copy context, like primary key fields, into globals Use Conditions to test those values If they are not set yet, show an error message If they are set, Open the desired function In the target form, – Create a rule that sets the initial value of those globals to null, to insure they exist – Then test them: if they are not null, {this is where other strategies, discussed later, could be used} Invoke QBE mode on the appropriate block Copy the values into base table fields Execute the query Clear the globals 1-17
Copyright © 2004, Oracle. All rights reserved.
Zooming: One Strategy, continued To open the desired function Create an Action of type Builtin, with the Type FND_FUNCTION.EXECUTE This example would open the Responsibilities form (after first checking security):
1-18
Copyright © 2004, Oracle. All rights reserved.
Zooming: One Strategy, continued Rules in the target form Rule 1: – –
Trigger Event: WHEN-NEW-FORM-INSTANCE Action: For one of the global variables being passed, set its INITIAL VALUE property to null (empty) This makes sure the next rule will not fail when the form is opened standalone
Rule 2: – – – – –
1-19
Trigger Event: WHEN-NEW-FORM-INSTANCE Condition: test if that global variable is not null Action 1: Builtin GO_BLOCK to the block you want to query Action 2: Builtin DO_KEY with ENTER_QUERY to invoke QBE Don’t put more actions here - they will not fire!
Copyright © 2004, Oracle. All rights reserved.
Zooming: One Strategy, continued Rules in the target form, continued Rule 3: – – – –
–
–
1-20
Trigger Event: WHEN-NEW-RECORD-INSTANCE, for the block you are querying Condition: test if that global variable is not null ‘Fire in Enter-Query’ mode checked Action 1+: set the VALUE of the appropriate fields to have the values of the globals you passed The Value is of the format “=:global.” Create an Action for each variable you need to process Action 2+: Set the VALUE of the globals to null (empty) This prevents future queries from re-running just this one Create an Action for each variable you need to process Action 3: Builtin DO_KEY with EXECUTE_QUERY to run the query Copyright © 2004, Oracle. All rights reserved.
Zooming: Other Strategies Each form in Oracle Applications has its unique quirks. You may discover other ways to force it to query: The target function may already accept the value(s) as an input parameter – – – –
Use the ‘Add Parameters’ button to see parameters associated with other functions on the same form Note that this will not reveal every parameter that a function takes, nor its intended usage Examining source code is the only way to know exactly how parameters work Oracle does not warrant that a parameter will exist or function the same after a patch
In forms that have Find Windows, it may be possible to populate the appropriate field(s) in the Find window, then issue builtin DO_KEY with argument NEXT_BLOCK 1-21
Copyright © 2004, Oracle. All rights reserved.
Zooming: Other Strategies, continued
You could modify the DEFAULT_WHERE clause of the appropriate block, then query it using DO_KEY with argument EXECUTE_QUERY, then reset the DEFAULT_WHERE clause back to its original value
A little bit of experimentation and creativity is all it takes! Zooms need to be extensively tested after a patch because of their inherent complexity
1-22
Copyright © 2004, Oracle. All rights reserved.
Summary In this module, you should have learned how to: Work with GLOBAL variables, including the differecnes between the properties VALUE and INITIAL VALUE Understand Oracle Forms Query-by-Example (QBE) mode Create Special menu entries, and write Rules that respond to their selection ‘Zoom’ to other functions, and various strategies to try
1-23
Copyright © 2004, Oracle. All rights reserved.