Introduction to Sprinkler
Installation and Setup
Documentation
How-To's
Disclaimers
Introduction to Sprinkler
Installation and Setup
Documentation
How-To's
Disclaimers
With Sprinkler, developers can use the new “On Demand” replication function.
This feature will allow you to manage, for example, the following scenarios:
There is a public Function of [Spk Management] codeunit that allows you to reach the goal:
Replicate_Record(parmRecord : Variant, Peer : GUID)
parmRecord: can be both Record and RecordRef type variable
Example - You need to replicate to a remote historical database the data of tables [Sales Invoice Header], [Sales Invoice Line] and corresponding [G/L Entry] so you can navigate those documents correctly. All the documents with [Posting Date] up to 12/31/2016 must be copied. We suppose that the schema of all involved tables are identical in Source and Target Peer's databases.
Before to start, in the Target Peer you have to create the following Importing Setup for all [Sales Invoice Header], [Sales Invoice Line] and [G/L Entry] tables: this setup will be active in ~1 minute; the user declared as [Data Distribution Service User] on Target Peer must have Insert and Modify permission on destination table. No further setup are required on Source Peer, because this function will send ALL fields belonging to source table. Of course, the user operating the following code must have the Permission Set EERIS SPK USER, and Read permissions on source table.
Solution - Create the following variables:
Name | DataType | SubType |
---|---|---|
SpkMgt | Codeunit | Spk Management |
Peer | Record | Data Distrib. Peer |
SalesInvHdr | Record | Sales Invoice Header |
SalesInvLine | Record | Sales Invoice Line |
GLEntry | Record | G/L Entry |
The code is:
LastDate := 311220D; Peer.GET('{60632e40-a50d-11e7-9598-0800200c9a66}'); //exemple of Remote Peer ID SalesInvHdr.SETFILTER("Posting Date",'<=%1',LastDate); IF SalesInvHdr.FINDSET THEN REPEAT SpkMgt.Replicate_Record(SalesInvHdr,Peer."Server ID"); SalesInvLine.SETRANGE("Document No.",SalesInvHdr."No."); IF SalesInvLine.FINDSET THEN REPEAT SpkMgt.Replicate_Record(SalesInvLine,Peer."Server ID"); UNTIL SalesInvLine.NEXT = 0; GLEntry.SETRANGE("Document Type",GLEntry."Document Type"::Invoice); GLEntry.SETRANGE("Document No.",SalesInvHdr."No."); IF GLEntry.FINDSET THEN REPEAT SpkMgt.Replicate_Record(GLEntry,Peer."Server ID"); UNTIL GLEntry.NEXT = 0; UNTIL SalesInvHdr.NEXT = 0;