Fusion Concepts: FND_MESSAGES

In the previous post of this series, we talked about translation support in Fusion Applications. We discussed on how language specific data is handled by ADFbc entities. This post covers on how errors and warnings messages are implemented in Fusion Applications using FND_Messages. People from the EBiz World would already be familiar with the term 'FND'.  Just for the information purpose 'FND' is derived as a short name from Applcore and taken from the word 'FouNDation'. FND_Messages are translatable messages that are keyed by a message name and a product code. These messages are stored in the database as opposed to resource bundles. This is due to the fact that resource bundles can be accessed only from java programs and FND_Messages are required to be accessed from non java code too. The FND_Message tokens differ from the resource bundle message tokens in being named tokens rather than positional tokens. FND_Messages are used only for throwing error and warning messages e.g. for throwing entity validation exceptions. FND_Messages can also be used for throwing error and warning messages programmatically or through groovy.

FND_Messages Structure

FND_Messages requires the following information to be seeded:
  • Message Type: It could be Error, Warning or Information
  • Message Category: It's a broader level category to group similar messages like belonging to concurrent program, EO validations or any other categorization decided by product teams
  • Message Severity:  This can be set to High, Medium and Low. From usage perspective UI Message Popups can use this field to show an icon, end user can subscribe to notifications depending upon the severity of the messages.
  • Message Number: Internally every product is assigned a range of numbers to choose a message number which is previously not used. However, message number can be null or non unique and hence while extending Fusion Applications it can be any value.
  • Message Context:  This field is used by developers and translations to understand the intent of the message.
  • Message Text: This is the actual message visible to the end user and it may contain tokens which can be replaced at runtime with error specific details e.g "Enter an effective date that is the same as or later than {MATURITY_DATE}". Identifier under curly braces is a token in this case.
  • Message User Detail: This is a more detailed explanation of the message to help end user to take appropriate decision.
  • Message Admin Detail: This is seen by only administrators and may contain technical or functional details for understanding and resolving the issues.
  • Message Cause: This explains why the message appeared.
  • Message User Action: This explains the steps or instructions end user must perform in order to fix the problem message is reporting.
  • Message Admin Action: This explains the possible action for the administrator in order to resolve the issue.

Example

Here is an example of a FND_Messages row 

Using FND_Messages

As said above, FND_Messages can be used declaratively as well as programatically. Below are more details on each type of approach:

Declaratively:

When building declarative validators on entity objects, you can reference the FND_Messages Resource Bundle for associating error or warning messages. These messages can contain named message tokens for retrieving and displaying context sensitive values. To associate an error message from the FND_Message Resource Bundle with your validator follow these steps:

Go to the Failure Handling tab of your declarative validator when you have finished defining your rule. In the Validation Failure Severity field, Select Error.

If your message contains tokens, bind them to Groovy expressions to retrieve context sensitive values. Groovy script is a java-like scripting language. For more information about Groovy script visit here.

Within Java code, you can throw JboExceptions and JboWarnings to present application errors. You can use the FND_Message Resource Bundle to present error and warning messages within your EntityImpl class. The following are some examples of how you can use the FND_Message Resource Bundle to throw exceptions from your entity class:

To raise a generic (page level) exception:

import oracle.apps.fnd.applcore.messages.FndMessagesUtil;
import oracle.apps.fnd.applcore.messages.model.util.Util;
 
 throw new JboException(FndMessagesUtil.FndResourceBundle.class
/*FND Resource Bundle Class*/,"<AppCode:::<MessageName>",Util.untokenize("<AppCode:::<MessageName>",
(Object) "<TokenName1>", "<Token replacement text1>","<TokenName2>", "<Token replacement text2>",
"<TokenName3>", "<Token replacement text3>","<TokenName4>", "<Token replacement text4>",...)); 


To raise a row level validation exception:

import oracle.apps.fnd.applcore.messages.FndMessagesUtil;

throw new RowValException(
FndMessagesUtil.FndResourceBundle.class/*FND Resource Bundle Class*/,
"<AppCode:::MessageName>" /*Error Code: <AppCode:::<MessageName>*/,
getEntityDef().getFullName() /*EO Def Name*/
,getKey() /*EO primary key*/,
(ArrayList) null);

To raise an attribute level validation exception:

import oracle.apps.fnd.applcore.messages.FndMessagesUtil;

throw new AttrValException(AttrValException.TYP_ENTITY_OBJECT,
FndMessagesUtil.FndResourceBundle.class /*FND Resource Bundle Class*/,
"<AppCode:::<MessageName>" /*Error Code: <AppCode:::<MessageName>*/,
getEntityDef().getFullName() /*EO Def Name*/,
"EmailAddress" /*EO attribute name*/,
"bad value" /*EO attribute value*/,
null /*detail exceptions*/,
false /*not a bundled exception*/);

To throw an exception with tokens attached:

Map params = new HashMap(),
 params.put ("<TokenName>", "source.hints.UserName.label")
 /* token name is <TokenName>*/,
attrException.setErrorParametersMap(params),
throw attrException; 

Using MessageServiceAM

Applcore's ready to use MessageServiceAM can be used to display messages from your application without hard-coding them into the application code. Messages are available through the oracle.apps.fnd.applcore.messageService.MessageServiceAM. Messages are fetched from the message dictionary and formatted using the specified tokens:

import oracle.apps.fnd.applcore.messages.messageService.MessageServiceAM;
import oracle.apps.fnd.applcore.messages.model.util.Util;

MessageServiceAM svc =(MessageServiceAM)((OAApplicationModeleImpl)
getDBTransaction().getRootApplicationModule())).getFNDNestedService
(OAConstants.MESSAGE_SERVICE);

Map<String,String> tokens = new TreeMap<String,String>();
tokens.put("<TokenName1>","<Token replacement text1>");
tokens.put("<TokenName2>", "<Token replacement text2>");
String adminText = svc.formatAdminText("<AppCode>",
 "<MessageName>",
Util.mapToList(svc.getTokenValue(),
tokens));

Resources

Link related to Messages can be found in Developer Guide

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Follow us on twitter Fusion Applications Extensibility, Customizations and Integration forum Fusion Applications Dev Relations YouTube Channel
This blog offers news, tips and information for developers building extensions, customizations and integrations for Oracle Fusion Applications.

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
4
5
6
8
11
12
13
15
16
18
19
20
22
23
24
25
26
27
28
29
30
   
       
Today