Concatenate Documents From Two Xpaths

<< Click to Display Table of Contents >>

Navigation:  Bizagi Studio > Process wizard > Business Rules > Business rules examples > Concatenate Documents >

Concatenate Documents From Two Xpaths

Overview

This section describes how to use the feature to concatenate documents from two different Xpaths.

 

Example

In the following sample process, assume we have a process entity called OfficeSupplyRequest.

Such process uses the following data model:

 

ProductRequestDataModel

 

We want the attribute Request Summary to have the information uploaded into Quotation Request and Invoice attributes. To do so we will use the Concatenate documents from two Xpaths method.

 

note_pin

The documents to concatenate should be the same format, either PDF or Microsoft Word document. Otherwise, the method will not work correctly.

 

Concatenating Word Documents

In this case the syntax of the function is:

 

CHelper.ConcatDocumentsFromTwoXpathsToWord(Me, fileXpath1, fileXpath2)

 

The main parameters of this function are:

The first parameter (Me) is fixed.

The fileXpath1: the Xpath to the first document as a string.

The fileXpath2: the Xpath to the second document as a string.

 

To concatenate the files of our example we will need an expression box:

 

concatdoc_2xpath_doc

 

The expression above is as follows:

var file = CHelper.ConcatDocumentsFromTwoXpathsToWord(Me,"OfficeSupplyRequest.QuotationRequest","OfficeSupplyRequest.Invoice");
var File = Me.newCollectionItem("OfficeSupplyRequest.RequestSummary");
File.setXPath("FileName", "RequestSummary_" + Me.Case.Id + ".docx");
File.setXPath("Data", file);

 

The resulting file will have as name RequestSummary_[CaseNumber].docx.

 

note_pin

Please make sure the file extension matches the document type the method uses.

 

Concatenating PDF Documents

In this case the syntax of the function is:

 

CHelper.ConcatDocumentsFromTwoXpathsToPdf(Me, fileXpath1, fileXpath2)

 

The main parameters of this function are:

The first parameter (Me) is fixed.

The fileXpath1:  the Xpath to the first document as a string.

The fileXpath2: the Xpath to the second document as a string.

 

To concatenate the files of our example we will need an expression box:

 

concatdoc_2xpath_pdf

 

The expression above is as follows:

var file = CHelper.ConcatDocumentsFromTwoXpathsToPdf(Me,"OfficeSupplyRequest.QuotationRequest","OfficeSupplyRequest.Invoice");
var File = Me.newCollectionItem("OfficeSupplyRequest.RequestSummary");
File.setXPath("FileName", "RequestSummary_" + Me.Case.Id + ".pdf");
File.setXPath("Data", file);

 

The resulting file will have as name RequestSummary_[CaseNumber].pdf.

 

note_pin

Please make sure the file extension matches the document type the method uses.