Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Panel
nameblue

This section describes how error, warning, and question messages are created.

 

What does this section cover?

Table of Contents

Error Messages

Expand
titleError Message

Image Added

In order for an error message to appear on screen, a java exception must be created and thrown.  

  1. Create the Exception class. 
    1. All exception classes must extend com.crm.exception.CRMValidationException
    2. All exception methods should have a com.crm.exception.CRMValidationException object as an input parameter and use setMessage method of com.crm.exception.CRMException class.
      1. To create the exception method:
        1. Use com.crm.businessobject.CRMSession object as an input parameter and any other String input parameters needed.
        2. Put all String input parameters in a String ArrayList.
        3. Use setMessage method of com.crm.exception.CRMException class to construct the exception message.

...

      2. Define the exception in the messages.xml file. Use a unique key for the expression tag.  For more information on customising messages metadata, go to Customize Messages Metadata.

Code Block
languagexml
titlemessages.xml
collapsetrue
<messages>
	<message>
		<code>COM.CRM.EXCEPTION.ACCOUNTS.ACCOUNTTERMINATIONEXCEPTION</code>
		<expression>key_com_crm_exception_accounts_accountterminationexception</expression>
		<description>You are not allowed to terminate the accounts receivable. This is only allowed for Active or Suspended accounts.</description>
	</message>
	.
	.
	.
</messages>

      3. Define the exception in English translation properties file, by using the expression tag key defined in metadata messages file as the entry key, and specifying the exception message. Use %<number> where the input parameters should be placed. Note that <number> is their index+1 in parameters array list.

...

      3. Define the question code in metadata messagesin metadata messages file.

Code Block
themeEclipse
languagejava
titlemessages.xml
collapsetrue
 	<message>
         <code>CONFIRM_FINANCIAL_TRANSACTION_SAVED_AS_POSTED</code>
         <expression>key_confirm_financial_transaction_saved_as_posted</expression>
         <description>Confirm Action</description>
    </message>

      4. Define the question in the English translation properties file, by using the expression tag key defined in metadata messages file in metadata messages file as the entry key, and specifying the question message. Use %<number> where the message parameters should be placed. Note that <number> is their index+1 in message parameters array list.

Code Block
themeEclipse
languagejava
titletranslation_eng.properties
collapsetrue
 	<entry key="key_confirm_financial_transaction_saved_as_posted">%1 is going to be saved as Posted. Do you wish to continue?</entry>

...

Informational Messages

...

The last example is about showing warning messages and as previously the same procedure is been followed. The following example constructing a warning message about the license on its interface class. Firstly, an InfoMessage object is created and some parameters are parsed. The first parameter is the crmSession, second the code of the message, third are some message parameters, then the path of the session and the organization id as follows. Lastly, the showInfoMessage method is called to demonstrates the warning message on the screen by parsing the message details.

...

Expand
titleInformational Message

Image Added

In order for n informational message to appear on screen, you have to 

  1. Create an instance of com.crm.process.InfoMessage object, defining the session, message code, message parameters, session real path, and organisation id as shown below.
  2. Use showInfoMessage method of com.crm.process.CRMUI class to display the message on screen.
Code Block
themeEclipse
languagejava
titleInfoMessage saveGeneralSetting method
collapsetrue
		/**
	InfoMessage infoMsg* =Saves new InfoMessage(getCRMSession(),
                "LOGOUT_INFO_MSG", 
        a general setting.
	 * 
	 * @param generalSetting - the general setting to save
	 * @return the saved general setting	
	 * @throws Exception
	 */
    public GeneralSetting saveButton(GeneralSetting new String[]{"Payment"},
 generalSetting) throws Exception {
    	
    	systemSettingBean.validateGeneralSettings(generalSetting);
    getCRMSession().getRealPath(),	systemSettingBean.saveGeneralSettings(generalSetting);
    	
    	InfoMessage infoMsg=new InfoMessage(getCRMSession(),"LOGOUT_INFO_MSG",      null, getCRMSession().getRealPath(), getOrganisationID());
    	
    	showInfoMessage(infoMsg);
    	
    	return generalSetting;
    }

 

Once again, the code of the warning message must be defined in messages of metadata file whilst the expression key must also be mentioned in labels file, as follows.

 

      3. Define the message code in metadata messages file.

Code Block
themeEclipse
languagejava
titlemessages.xml
collapsetrue
	<message>
        <code>LOGOUT_INFO_MSG</code>
        <expression>key_logout_info_msg</expression>
        <description>Logout to apply the changes</description>
    </message>

      4. Define the message in the English translation properties file, by using the expression tag key defined in metadata messages file as the entry key, and specifying the question message. Use %<number> where the message parameters should be placed. Note that <number> is their index+1 in message parameters array list.

Code Block
themeEclipse
languagejava
titletranslation_eng.properties
collapsetrue
	<entry key="key_logout_info_msg">Please logout and login again so thethat changes will be applied.</entry>

 

Then, on the following screen is illustrated the warning message, when a field is been changed.

 

Expand
titleWarning Message

Image Removed

 

...