In this article we will present a broker we have developed. This service allows us to copy the entire content of a word document and place it within a specific content control of another word document.
I- Download et Installation of the broker
Download the DLL cliquantici. Thenunzip the archive.
Place the .DLL file in the ServiceBroker folder of the K2 installation directory (default C:\Program Files (x86)\K2 blackpearl\ServiceBroker)
Open the SmartObject Service Tester tool by double-clicking SmartObject Service Tester.exe socated in the K2 bin directory (default: C:\Program Files (x86)\K2 blackpearl\Bin\SmartObject Service Tester.exe)
- on the window that opens, click the Register ServiceType. In the window that opens, select the name of the service to install, which is the name of the .dll file, in our case FFField.DocumentCopyToSpecificPlaceWordDoc.FFService.
Once the service has been selected, simply fill in the fields:
- System Name: you can leave it as is or change it (as long as there are no special characters or spaces).
- Display Name: the name that will appear in the design tools (special characters allowed).
- Description: a description of our service broker, this part is not mandatory, but important to remind us of the role of our service.
- Guid : to leave as is during the original installation. Keep this ID and reuse it when deploying the broker on your other environments).
As in the figure below:
Then click Add. A new service type with the name specified in the Display Name (CopyToSmartObject in our case), was created appears in the ServiceObject Explorer.
Then go to ServiceObject Explorer: On this Service Type: right-click > Register ServiceInstance In the window that opens, specify:
- Service Types which is the name of the service instance
- Authentication mode: the broker’s execution account (the account that will therefore interact with the data source). The choice will depend on how you want to connect to the data source and the associated permissions. In our case we will choose: Impersonate
- Then click on Next.
- Fill in the System Name and Display Name in the pop-up that appears (same constraints as before, it is this time the name of the instance of the broker ). Then press Add.
II- Creation of the SmartObject link to the broker
Note: When updating a broker service, the DLL file to replace will be blocked by the K2 service (and therefore not replaceable). It is then necessary to restart the service K2 to do the manipulation.
III- Running the service broker
First of all, we will create two word documents:
- The documen which will be copy MyDoc.docx in our case.
- Document into which the first document will be copied Template.docx in our case. The document Template.docx must content à content control name with title DOC_Body
The smartObject created in the previous section will be present in the Default subfolder of the SmartObject Explorer folder as shown in the 1image. below
Follow the steps below to run the broker
Then all the content of the word document MyDoc.docx document will be copied inside the content control DOC_Body of the document word Template.docx