Application messages

Access to translatable strings and messages stored in the application database message tables is implemented by the ApplicationDB class. The strings and messages that are returned are queried and constructed according to the calling session's regional settings. Access is provided through the IMessageProvider interface and makes use of application database messaging stored procedures such as MsgAppSp.

These methods are published by the IMessageProvider interface:

Method Description
public string GetMessage(
   string msgID) 
Gets a string or message by message ID
public string AppendMessage(
   string message,
   string msgID)
Appends a string or message by message ID
public string AppendMessage(
   string message,
   string msgID,
  params object[] args)
Appends a string or message by message ID with substitution parameters
public string GetErrorMessage(
   string objectName,
   AppMessageType messageType) 
Gets a constraint error message by object name and type
public string GetErrorMessage(
   string objectName,
   AppMessageType messageType,
   params object[] args)
Gets a constraint error message by object name and type with substitution parameters

Message lookup using the ApplicationDB class

This example shows how to use the ApplicationDB class to retrieve messages:

IMessageProvider messageProvider = null;
using (ApplicationDB appDB = this.CreateApplicationDB()) 
{ 
   messageProvider = appDB.GetMessageProvider(); 
   Infobar = messageProvider.AppendMessage(Infobar, "I=CmdMustPerform", 
   "@:PostPendingMaterialTransactions"); 
} 

If you are writing code in an extension class method for a class that derives from IDOExtensionClass, you can simply call the IDOExtensionClass.GetMessageProvider method as a shortcut to getting a reference to the IMessageProvider interface, as shown in this example:

IMessageProvider messageProvider = null; 
messageProvider = this.GetMessageProvider();