Sample Integration Type
This is the overview of the sample implementation of an Integration Type. The sample integration does not do anything meaningful, it just shows some messages when stepping through the steps in the integration.
Objects
The following table includes links to each of the objects that are being created in this sample
Object Type | Object Name | See |
---|---|---|
Codeunit | My IQIT Sample Handler | link |
Enum Extension | My IQIT Sample | link |
Codeunit My IQIT Sample Handler
/// <summary>
/// This is a sample implementation of an "IQ Integration Type".
///
/// Each integration that has some kind of custom processing of data will need to implement a new "IQ Integration Type".
/// </summary>
codeunit 50000 "My IQIT Sample Handler" implements "QWESR IQ Integration Type"
{
Access = Public;
TableNo = "QWESR Integration Queue";
// ************************************************************************************************************************
//
// All code in between "CUSTOMIZATION begin" and "CUSTOMIZATION end" must be updated to your specific needs
//
// ************************************************************************************************************************
trigger OnRun();
var
IQMain: Codeunit "QWESR IQ Main";
begin
Rec.Consistent(false); // Prevent any unwanted commits
case Rec."Next Step" of
// CUSTOMIZATION begin
// Replace the steps below to the steps defined in GetIntegrationSteps() in this implementation. One Case statement for each step.
"QWESR IQ Step"::Parse:
begin
ParseData(Rec);
end;
"QWESR IQ Step"::Validate:
begin
ValidateData(Rec);
end;
"QWESR IQ Step"::Post:
begin
PostData(Rec);
end;
// CUSTOMIZATION end
else
Error('Unknown step ''%1'' for integration ''%2''!', Rec."Next Step", Rec."Integration Setup Code");
end;
IQMain.SetNextStep(Rec); // This increases the "Next Step" on this record to the next step defined in this Integration Type, after the last defined step a default "Archive" step is set
Rec.Consistent(true); // Allow commits again
end;
/// <summary>
/// This function checks if an event is triggered for this Integration Type.
/// </summary>
/// <param name="IntegrationType">The Integration Type that triggered an event.</param>
/// <returns>true if the event was triggered for this Integration Type, otherwise false.</returns>
local procedure IsMyEvent(IntegrationType: Enum "QWESR IQ Integration Type"): Boolean
begin
// CUSTOMIZATION begin
// Replace "My Sample Integration"
exit(IntegrationType = "QWESR IQ Integration Type"::"My Sample Integration");
// CUSTOMIZATION end
end;
/// <summary>
/// This event is triggered when a record in the Integration Queue table is about to be deleted and has been copied to the History table.
/// This should be used to cleanup any data in other tables, related to this record.
/// If there are nothing to do in this event, don't use it.
/// </summary>
[EventSubscriber(ObjectType::Codeunit, Codeunit::"QWESR Integration Type Mgt.", 'OnAfterDeleteIntegrationQueue', '', false, false)]
local procedure IntegrationTypeMgt_OnAfterDeleteIQ(IntegrationType: Enum "QWESR IQ Integration Type"; var IQ: Record "QWESR Integration Queue")
var
SampleMsg: Label 'SAMPLE: Cleanup related tables for %1 %2', Comment = '%1 = "Integration Queue", %2 = Name';
begin
if not IsMyEvent(IntegrationType) then
exit; // If not this Integration Type -> exit
// CUSTOMIZATION begin
// Delete related data or move it to history tables
Message(SampleMsg, IQ.TableCaption(), IQ.Name);
// CUSTOMIZATION end
end;
/// <summary>
/// This event is triggered when a record in the Integration Queue History table is about to be deleted.
/// This should be used to cleanup any data in other tables, related to this record.
/// If there are nothing to do in this event, don't use it.
/// </summary>
[EventSubscriber(ObjectType::Codeunit, Codeunit::"QWESR Integration Type Mgt.", 'OnAfterDeleteIntegrationQueueHistory', '', false, false)]
local procedure IntegrationTypeMgt_OnAfterDeleteIQHistory(IntegrationType: Enum "QWESR IQ Integration Type"; IntegrationQueueHistory: Record "QWESR Integration Queue Hist")
var
SampleMsg: Label 'SAMPLE: Cleanup related tables for %1 %2', Comment = '%1 = "Integration Queue", %2 = Name';
begin
if not IsMyEvent(IntegrationType) then
exit; // If not this Integration Type -> exit
// CUSTOMIZATION begin
// Delete related data
Message(SampleMsg, IntegrationQueueHistory.TableCaption(), IntegrationQueueHistory.Name);
// CUSTOMIZATION end
end;
// Interface implementation (documented in the Interface object):
procedure GetIntegrationSteps(IntegrationType: Codeunit "QWESR Integration Type Mgt."; var tIQStepOrder: Record "QWESR tIQStepOrder" temporary)
begin
// CUSTOMIZATION begin
IntegrationType.AddIntegrationStep("QWESR IQ Integration Type"::"My Sample Integration", tIQStepOrder, "QWESR IQ Step"::Parse, Codeunit::"My IQIT Sample Handler");
IntegrationType.AddIntegrationStep("QWESR IQ Integration Type"::"My Sample Integration", tIQStepOrder, "QWESR IQ Step"::Validate, Codeunit::"My IQIT Sample Handler");
IntegrationType.AddIntegrationStep("QWESR IQ Integration Type"::"My Sample Integration", tIQStepOrder, "QWESR IQ Step"::Post, Codeunit::"My IQIT Sample Handler");
// CUSTOMIZATION end
end;
procedure ArchiveData(IQ: Record "QWESR Integration Queue")
// CUSTOMIZATION begin
var
SampleMsg: Label 'SAMPLE: Archive related data for "%1"', Comment = '%1 = Name';
begin
Message(SampleMsg, IQ.Name);
// CUSTOMIZATION end
end;
procedure IsIntegrationQueueDeletionAllowed(var IQ: Record "QWESR Integration Queue"): Boolean
// CUSTOMIZATION begin
var
SampleMsg: Label 'SAMPLE: Deletion is allowed for "%1"', Comment = '%1 = Name';
begin
Message(SampleMsg, IQ.Name);
exit(true);
// CUSTOMIZATION end
end;
procedure IsIntegrationQueueImportDeletionAllowed(var IQImport: Record "QWESR Integration Queue Import"): Boolean
// CUSTOMIZATION begin
var
SampleMsg: Label 'SAMPLE: Deletion of import records are allowed for "%1"', Comment = '%1 = Name';
begin
Message(SampleMsg, IQImport.Name);
exit(true);
// CUSTOMIZATION end
end;
procedure ShowDetails(IQ: Record "QWESR Integration Queue") rHandled: Boolean
// CUSTOMIZATION begin
var
SampleMsg: Label 'SAMPLE: Show related tables for %1 %2', Comment = '%1 = "Integration Queue", %2 = Name';
begin
Message(SampleMsg, IQ.TableCaption(), IQ.Name);
exit(true);
// CUSTOMIZATION end
end;
procedure ShowHistoryDetails(IntegrationQueueHistory: Record "QWESR Integration Queue Hist") rHandled: Boolean
// CUSTOMIZATION begin
var
SampleMsg: Label 'SAMPLE: Show related tables for %1 %2', Comment = '%1 = "Integration Queue History", %2 = Name';
begin
Message(SampleMsg, IntegrationQueueHistory.TableCaption(), IntegrationQueueHistory.Name);
exit(true);
// CUSTOMIZATION end
end;
procedure AnalyzeHistory(IntegrationQueueHistory: Record "QWESR Integration Queue Hist") rHandled: Boolean
// CUSTOMIZATION begin
var
SampleMsg: Label 'SAMPLE: Analyze data for %1 %2', Comment = '%1 = "Integration Queue History", %2 = Name';
begin
Message(SampleMsg, IntegrationQueueHistory.TableCaption(), IntegrationQueueHistory.Name);
exit(true);
// CUSTOMIZATION end
end;
procedure AdditionalSettingsIsSupported(): Boolean
begin
// CUSTOMIZATION begin
exit(false);
// CUSTOMIZATION end
end;
procedure ShowAdditionalSettings(IntegrationSetupCode: Code[20]) Handled: Boolean;
begin
// CUSTOMIZATION begin
exit(false);
// CUSTOMIZATION end
end;
procedure ClearAdditionalSettings(IntegrationSetupCode: Code[20]) Handled: Boolean;
begin
// CUSTOMIZATION begin
exit(true);
// CUSTOMIZATION end
end;
// CUSTOMIZATION begin
/// <summary>
/// This sample function may parse the data blob and save the parsed data in different tables in the database.
/// </summary>
/// <param name="IntegrationQueue">The record being processed.</param>
local procedure ParseData(var IntegrationQueue: Record "QWESR Integration Queue")
var
SampleMsg: Label 'SAMPLE: Parse data for "%1"', Comment = '%1 = Name';
begin
Message(SampleMsg, IntegrationQueue.Name);
end;
/// <summary>
/// This sample function may validate the parsed data and throws error if data is unexpected.
/// </summary>
/// <param name="IntegrationQueue">The record being processed.</param>
local procedure ValidateData(var IntegrationQueue: Record "QWESR Integration Queue")
var
SampleMsg: Label 'SAMPLE: Validate data for "%1"', Comment = '%1 = Name';
begin
Message(SampleMsg, IntegrationQueue.Name);
end;
/// <summary>
/// This sample function may post the parsed data.
/// </summary>
/// <param name="IntegrationQueue">The record being processed.</param>
local procedure PostData(var IntegrationQueue: Record "QWESR Integration Queue")
var
SampleMsg: Label 'SAMPLE: Post data for "%1"', Comment = '%1 = Name';
begin
Message(SampleMsg, IntegrationQueue.Name);
end;
// CUSTOMIZATION end
}
Enum Extension My IQIT Sample
An Enum Extension is created to make the new Integration Type a selectable Integration Type in the UI.
enumextension 50001 "My IQIT Sample" extends "QWESR IQ Integration Type"
{
value(50001; "My Sample Integration")
{
Caption = 'My Sample Integration';
Implementation = "QWESR IQ Integration Type" = "My IQIT Sample Handler";
}
}
See Also
Extend Integration Queue
How to Create a Custom Integration Type