Link

Message API

Table of contents

  1. Description
  2. Features
    1. getMessage
      1. getMessage(String sysComp, String language, String messageId, List parameters)
      2. getMessage(String messageId, List parameters)
  3. Considerations and Guidelines

Since: 0.1.0
Context: Any
Category: Generic

Description

Message API is a tool used in a Trigger type extensions and Transaction type extensions. This API provides capabilities for receiving information about an error from running program. User using MessageAPI can retrieve an error message by using built in method called getMessage. It allows to combine the error message with another components (ex. Interactive API with pop-up window etc.) inside the extension. The result of the Message API is an information extracted from the message file, which is displayed on the screen using other API elements in the extension.

Features

getMessage

It retrieves an error message from the error files into the component of the running program. There are two ways to use the getMessage method:

getMessage(String sysComp, String language, String messageId, List parameters)

  • String sysComp - System component for the specific market (M) - ex. for Poland is MPL (M-PL)
  • String language - Language code (language of specific message, for example GB. It works depends on the programmed messages)
  • String messageId - Message Id from the message files
  • List parameters - List with parameters (max. 4 inside list) to insert into a message
public class MessageAPI_TEST extends ExtendM3Trigger {
  private final MessageAPI message;
  private final InteractiveAPI interactive;

  public MessageAPI_TEST(MessageAPI message, InteractiveAPI interactive) {
    this.message = message;
    this.interactive = interactive;
  }
  
  public void main() {
    //getMessage returns String type value, so it is visible inside a pop-up (showOkDialog) window
    interactive.showOkDialog(message.getMessage("MVX","GB","CR_0091",["WRX","XTC","STB","KWS"])); 
  }
}

Provided error message is presented below:

getMessage(String messageId, List parameters)

  • String messageId - Message Id from the message files
  • List parameters - List with parameters (max. 4 inside list) to insert into a message

Example of simple MessageAPI usage with getMessage method:

public class MessageAPI_TEST extends ExtendM3Trigger {
  private final MessageAPI message;
  private final InteractiveAPI interactive;

  public MessageAPI_TEST(MessageAPI message, InteractiveAPI interactive) {
    this.message = message;
    this.interactive = interactive;
  }
  
  public void main() {
    interactive.showOkDialog(message.getMessage("XC00001",[]));  // when the message files don't use parameters it is necessary to leve an empty list inside getMessage
  }
}

Provided error message is presented below:

List parameters usage

Parameters applied inside getMessage constructor are used in messages which have specifically allocated spaces (&1, &2 etc.) for the use of parameters. To insert less inputs inside message, use empty Strings.

  // code sample from the getMessage(String sysComp, String language, String messageId, List<String> parameters) example:
  interactive.showOkDialog(message.getMessage("MVX","GB","CR_0091",["WRX","XTC"]));

Provided error message with 2 empty parameters is presented below:

Considerations and Guidelines

Method API is a tool to retrieve an error message from message files and inject it into some program components. It can be used with the Interactive API, to perform message visibility while running a program.