Skip to content

Creation of an entity queue outbound message

For the sake of explanation, this manual will implement a fake message "Tutorial Outbound Integration". We will abbreviate this in code as "TUTOutIntegration".

In order to develop this message, first follow the manual to create a simple outbound message.

This document describes the changes needed to the message that has been created using the above manual.

Type class

In the type class, override the implementsOutboundEntityQueueFramework method to return true.

protected boolean implementsOutboundEntityQueueFramework()
{
    return true;
}

Creation class

This class is responsible for the creation of data in our staging tables. It should extend from the framework class SMRIFCreateOutEntityQueueMessage, as opposed to SMRIFCreateOutMessage for a simple message.

At the very basis, the class declaration should look like this:

public class TUTCreateOutIntegration extends SMRIFCreateOutEntityQueueMessage
{
}

Implementing this subclass of SMRIFCreateOutMessage brings along three new abstract methods that must be implemented, as well as a couple of other changes.

initializeFromOutboundEntity

This method replaces the static create method we implemented. Instead, we will inject our SomeTable record here based on the reference fields in the outboundEntityQueue record.

protected void initializeFromOutboundEntity()
{
    this.someTable = SomeTable::findRecId(outboundEntityQueue.RefRecId);
}

completeMessageProperties

This method fills properties on the SMRIFMessage record. As opposed to the simple outbound messages, it is important do do a super() call here in order to fully utilize the functionality of the outbound entity queue feature.

referenceFieldId

This method should return the fieldId of a (unique) identifier of your SomeTable record that is being interfaced. This is used to display the record in the user interface. For example on a customer, this might be his account number.

public FieldId referenceFieldId()
{
    return fieldNum(SomeTable, SomeIdentifyingField);
}

getEditableInterfaceFields

This method will return, given a TableId, a set of fields that should trigger an update in the interface. When one of these fields changes, a new record in the queue will be created.

public Set getEditableInterfaceFields(RefTableId _tableId)
{
    // return a seperate set for every table involved in the outbound interface, return the one asked for by the _tableId parameter.
    // add all the fields that are used to determine the contents of the outbound interface message and can be edited after creation of the entity
    // This is used to determine if a new message should be sent when this table is changed
    // ONLY include the fields that can be modified!

    switch(_tableId)
    {
        Set set = new Set(Types::Integer);

        case tableNum(SomeTable):
            set.add(fieldNum(SomeTable, HeaderField1));
            set.add(fieldNum(SomeTable, HeaderField2));
            break;
        case tableNum(SomeLine):
            set.add(fieldNum(SomeLine, LineField1));
            set.add(fieldNum(SomeLine, LineField2));
            break;
        default:
            Throw Exception::Error;
    }

    return set;
}

Triggers

When an event happens in Dynamics that is applicable for interfacing, we should trigger the interface framework.

In our example, this could be a CRUD action on either the SomeTable or the SomeLine table.

This is done by using the SMRIFTriggerOutboundEntity class. This class offers three static methods for triggering the framework:

  • triggerCreate
  • triggerDelete
  • triggerUpdate

The triggerCreate and triggerDelete methods are straightforward:

SMRIFTriggerOutboundEntity::triggerCreate(SMRIFMEssageTypes::TUTOutIntegration, SomeTable, [createdRecord]);
SMRIFTriggerOutboundEntity::triggerDelete(SMRIFMEssageTypes::TUTOutIntegration, SomeTable, [deletedRecord]);

Here, the createdRecord or deletedRecord can be the SomeTable record itself, but they can also be a record that is related to the SomeTable record. This means that for example, a 'phone number creation' event on a customer should be handles using the triggerCreate() method, even though we aren't creating the customer itself. The framework will automatically convert such a create or delete operation in to an update operation when needed.

In case of an update operation, the triggerUpdate() method can be used. This method requires an extra parameter:

SMRIFTriggerOutboundEntity::triggerCreate(SMRIFMEssageTypes::TUTOutIntegration, SomeTable, [updatedRecordOrig], [updatedRecordNew]);

When calling this method, the framework will analyse the differences between the updatedRecordOrig and updatedRecordNew records in order to determine if a relevant change was made. It will then queue an interface message for the SomeTable record if needed.

Typically, these triggers are called in the insert, update and delete methods of the relevant tables.