Create Messages

Learn how to create messages in Golden EDI to export, validate or trigger actions.

By following this guide, you'll be able to make the most out of the CheckMessageToCreate function in Golden EDI. Have questions? Feel free to reach out!

Introduction

The CheckMessageToCreate function is an essential part of Golden EDI's message queue architecture. This guide aims to provide a comprehensive understanding of how to utilize this function for various purposes, such as exporting to our Cloud Integration Platform, triggering actions, and more.

GEDI Message Queue

Messages in the GEDI Message Queue serve multiple roles—importing, exporting, validation, and action triggering. Creating a queue line with the correct parameters allows Golden EDI to process the message as per the configuration settings. The processing can be an internal only process or generate data to be read by our Cloud Integration Platform to interface with external systems, processes or clients.

Function Signature

To create a message in the queue we have a public function called CheckMessageToCreate in the GEDI Management Codeunit. This method has the following signature:

GEDI Management
procedure CheckMessageToCreate(GEDIProfileCode: Code[10]; MessageID: Code[50]; MessageDocumentNo: Code[50]; MessageSelection: Integer; ManualImmediateRun: Boolean): Boolean;

Parameters:

  • GEDIProfileCode: The profile with which the message should be created.

  • MessageID: The ID of the message, often the document number for the record.

  • MessageDocumentNo: An additional document number.

  • MessageSelection: Indicates what kind of message to create.

  • ManualImmediateRun: Flag to indicate if immediate processing is required.

Return Value:

  • Returns true if a message was created; false otherwise.

Concepts

  • Profile and Selection: The combination of GEDIProfileCode and MessageSelection dictates whether a message should be created and its properties.

  • Multiple Queue Lines: A single call to this function can result in multiple lines in the queue based on the configuration.

  • MessageID: Usable from inside a mapping during processing of the message, allowing you to easily open the correct record.

  • MessageDocumentNo: Often the same as the MessageID, has no use except to make it possible to locate messages in the queue by an additional identifier.

  • Message Selection Hooks: Built-in selections like "Manual Hook 1" to "Manual Hook 10" are useful for adding listeners for new events. Other selections exist that can also be used.

Examples

Here you can find a collection of examples on how to utilize this function to create messages.

Export Warehouse Document

This is an example for how you would call the method for a Record pointing to an Warehouse Activity Header. The setup below uses the selection called Manual Hook 1 but you may choose another one depending your use case and system. The profile does not exist on the record so we use a fixed profile. You could use a conversion document or any other method of your choosing to dynamically select the profile as well.

procedure SendWhseDocument(var Rec: Record "Warehouse Activity Header")
var
    GEDIManagement: Codeunit "GEDI Management";
    GEDIMessageSelection: Record "GEDI Message Selection";
begin
    // Profile might exist on the document or you can set a fixed value
    SendingProfile := 'ONGOING';

    // We use the fixed profile and the "Manual Hook 1" selection to find the codes to create.
    GEDIManagement.CheckMessageToCreate(SendingProfile, Rec."No.", Rec."No.", GEDIMessageSelection.Usage::"Manual Hook 1", false);
end;

Process Immediately

This code example shows how you would use the RunMessageQueuemethod on GEDI Queue Handler in combination with CheckMessageToCreate to both create and process messages immediately. As you can see we call the RunMessageQueue with the same information used in the call to create one or more messages. The information we pass to the method is used to filter down the message queue to the specific lines we should process.

procedure CreateAndRunImmediately(var Rec: Record "Sales Invoice Header")
var
    GEDIManagement: Codeunit "GEDI Management";
    GEDIQueueHandler: Codeunit "GEDI Queue Handler";
    GEDIMessageSelection: Record "GEDI Message Selection";
    GEDIMessageQueue: Record "GEDI Message Queue";
begin
    // Try to create message(s) for the invoice that are configured to be processed immediately.
    if GEDIManagement.CheckMessageToCreate(Rec."GEDI Profile", Rec."No.", Rec."Order No.", GEDIMessageSelection.Usage::"Manual Hook 1", true) then begin
        // Since we did manage to create something, we can call the method "RunMessageQueue" on "GEDI Queue Handler" to actually process them immediately
        GEDIQueueHandler.RunMessageQueue(GEDIMessageSelection.Usage::"Manual Hook 1", Rec."GEDI Profile", Rec."No.", '', 0, false, '', false, GEDIMessageQueue);
    end;
end;

Last updated