MDMS events and functions
Events
In order to efficiently incorporate advanced business logic, MDMS now publishes the following events:
Codeunit ITI Replication Mgt.
OnBeforeExportRecord
Allows the user to specify if given record should be exported (e.g. when exporting a list of currencies – to avoid publishing a local currency. This can also be set up by using filters on the Replication card).
Parameters:
ReplicationNo [Code20]
ReceiverNo [Code20]
ExportedRecord [RecordID] = Specifies a record to be exported.
IncludeRecord [Boolean] = Specifies if the record will be exported.
VAR OverrideIncludeRecord [Boolean] = The parameter should be set to TRUE in order to override a default value.
VAR NewIncludeRecord [Boolean] = The parameter should be set to TRUE/FALSE in order to include or skip the record. This setup only works when combined with OverrideIncludeRecord set to TRUE.
VAR UseRecordLevel [Boolean] = The parameter should be set to TRUE/FALSE in order to use Record-Level functionality.
Example: (Currency CAD to be skipped from export):
[EventSubscriber(ObjectType::Codeunit, Codeunit::"ITI Replication Mgt.", 'OnBeforeExportRecord', '', false, false)]
local procedure OnBeforeExportRecord(ReplicationNo: Code[20]; ReceiverNo: Code[20]; ExportedRecord: RecordRef; IncludeRecord: Boolean; var OverrideIncludeRecord: Boolean; var NewIncludeRecord: Boolean; var UseRecordLevel: Boolean)
var
MyCurrency: Record Currency;
begin
if ExportedRecord.Number() = Database::Currency then begin
ExportedRecord.SetTable(MyCurrency);
if MyCurrency.Code = 'CAD' then begin
OverrideIncludeRecord := true;
NewIncludeRecord := false;
end;
end;
end;
OnAfterExportRecord
Allows you to perform actions on exported records.
Parameters:
ReplicationNo [Code20]
ReceiverNo [Code20]
TableNo [Integer]
RecordID [RecordID] = Specifies the record to be exported (RecordID)
ExportedRecord [RecordRef] = Specifies the record to be exported (RecordRef)
Codeunit ITI Record Synchronization Mgt.
OnAfterImportedRecordModify
Allows the user to perform actions on imported records.
Parameters:
VAR ModifiedRecord [RecordRef] = Specifies the record to be updated.
IsNewRecord [Boolean] = Specifies if the record was new or it existed before.
Example: (Updating the Currency Code field on the Customer card, this time on the receiving company side):
[EventSubscriber(ObjectType::Codeunit, Codeunit::"ITI Record Synchronization Mgt", 'OnAfterImportedRecordModify', '', false, false)]
local procedure OnAfterImportedRecordModify(var ModifiedRecord: RecordRef; IsNewRecord: Boolean)
var
MyCustomer: Record Customer;
begin
if ModifiedRecord.Number() = Database::Customer then begin
ModifiedRecord.SetTable(MyCustomer);
if MyCustomer."Currency Code" = 'CAD' then begin
MyCustomer."Currency Code" := '';
MyCustomer.Modify();
end;
end;
end;
OnBeforeExportRecordField
Allows you to override a default field value with your own function.
Parameters:
ITIRecordSyncEntry: [Record] "ITI Record Sync Entry"
ITIDataSetField: [Record] "ITI Data Set Field"
FieldValue [Text] = Specifies the currently exported field value
VAR OverrideFieldValue [Boolean] = This parameter should be set to TRUE in order to override default value
VAR NewFieldValue [Text] = This parameter should be to a new field value.
Example: (Currency Code CAD on Customer Card to be changed to <Blank> when exporting to Canada Receiver):
[EventSubscriber(ObjectType::Codeunit, Codeunit::"ITI Record Synchronization Mgt", 'OnBeforeExportField', '', false, false)]
local procedure OnBeforeExportField(ReplicationNo: Code[20]; ReceiverNo: Code[20]; TableNo: Integer; FieldNo: Integer; RecordID: RecordId; FieldValue: Text; var OverrideFieldValue: Boolean; var NewFieldValue: Text)
var
MyCustomer: Record Customer;
begin
if ReceiverNo <> 'CA' then
exit;
if TableNo = Database::Customer then
if FieldNo = MyCustomer.FieldNo("Currency Code") then
if FieldValue = 'CAD' then begin
NewFieldValue := '';
OverrideFieldValue := true;
end;
end;
OnBeforeSynchronizeData
Event fired before the data was imported to the receiving company (for each package).
Parameters:
- LastPackage: Boolean - Specify whether last package is importing.
OnAfterSynchronizeData
Event fired after the data was imported to the receiving company (for each package).
Parameters:
LastPackage: Boolean - Specify whether last package was imported.
IsError: Boolean - Specify whether error message has been thrown.
Codeunit ITI Record Delete Mgt.
OnBeforeRecordDeleted
Event fired before the record was deleted in the receiving company.
Parameters:
- DeletedRecordRef: RecordRef
OnAfterRecordDeleted
Event fired after the record was deleted in the receiving company.
Parameters:
DeletedRecordRef: RecordRef
RecordExists: Boolean - Specify whether record exists.
RecordDeleted: Boolean - Specify whether record was deleted.
Codeunit "ITI MDMS Record-Level Mgt."
OnAfterSetRecordReceiver
Allows you to do action after Record Receiver is set/unset(using for Record-Level functionality).
[EventSubscriber(ObjectType::Codeunit, Codeunit::"ITI MDMS Record-Level Mgt.", 'OnAfterSetRecordReceiver', '', false, false)]
local procedure OnAfterSetRecordReceiver(var RecordReceiver: Record "ITI Record Receiver"; IsReplicated: Boolean)
begin
end;
External functions
MDMS expose the following functions:
Codeunit ITI Log Mgt.
CreateTrackingLogEntries
Function allows to create Tracking Log Entry on which based incremental replication.
Parameters:
RecRef: RecordRef - Triggered RecordRef.
xRecRef: RecordRef - Trggered xRecordRef. Parameter can be blank if it's no rename.
IsIns: Boolean - true if insert
IsMod: Boolean - true if modify
IsRen: Boolean - true if rename
SetMDMSRun
Function set up global variable MDMSRun. If true then Local Block Insert, Local Block Modify Local Block Delete and Local Block Rename are not check (in the receiver).
Parameters:
- NewMDMSRun: Boolean
IsMDMSRun
Function return global variable MDMSRun.
Codeunit ITI Record Synchronization Mgt.
IsRecordSent
Function return true if given RecordID was sent to the Receiver. It checks that based on the Record Sync. Entries history.
Function knows whether record was sent and then delete. If that case function return false.
Parameters:
RecID: RecordId
ReceiverNo: [Code20]
Codeunit ITI One-Time Replication Mgt.
RunOneTimeReplication
Function allows to run One-Time Replication for given RecordID.
Parameters:
- RecID: RecordId