This article outlines how to set up a workflow that will generate a document that includes all child records that are related to a certain entity. Once the workflow is established, it will concatenate all these generated documents and send it to the account.
This feature is very useful if you, for example, would like to create a document that includes
– all quotes of a certain customer
– all contacts that are related to an account
– all invoices of a certain entity
In the now following step-by-step tutorial, we will create a document, that includes all contacts related to a certain account and concatenate it in one document.
Step 1: Create a new workflow for a random entity
If you have not created a workflow yet, please have a look at this blog article. In our example, we want to create a workflow for the entity account. Once the workflow is created, please add the DCPWorkflowSandbox: DCPCreateMultiPartXmlbassedonFetchxml step.
Step 2: Set the properties for the DCPWorkflowSandbox:DCPCreateMultiPartXmlbassedonFetchxml step
With a click on the [Set Properties]-button you add your individual properties to the parameters:
The first 3 properties allow you to define the settings for the conversion of the documents to .pdf and for the general SharePoint information. The other properties are explained below.
|· Template 1||Enables you to define the template which should be used|
|· Entity Record URL Base||Contain the Record URL of the Base Record (here: Account)|
|· FetchXML||Contains the FetchXML that resolves the relationship to the child.|
In this example, it retrieves all child contacts of the account.
|· FetchXMLResultField||Is the primary key field from the child record. In this case, it is the contactid|
|· FetchXMLResultEntity||Is the schema name of the result. In this example it is contact|
Step 3: Create a FetchXML
We recommend you to use a FetchXML builder if you want to create a new FetchXML.
The FetchXML that is created for this workflow:
– defines which documents should be filtered and concenated
– resolves the 1:N relationship
– enables you to add an unlimited amount of filters
Here is the FetchXML that was created for this example:
<fetch count=”50″ >
<entity name=”contact” >
<attribute name=”fullname” />
<link-entity name=”account” from=”accountid” to=”parentcustomerid” link-type=”inner” >
<filter name=”account” from=”accountid” to=”parentcustomerid” >
<condition attribute=”accountid” operator=”eq” value=”qid” />
It is of utmost importance that the qid (displayed above in red) is inserted because the workflow activity will replace the qid with the AccountId from the executed workflow. If qid is not inserted, the workflow cannot filter the results.
Figure 2: Set Custom Step Input Properties
Step 4: Create an AutoMergeWorkingItem
As the next step, you need to create the AutoMergeWorkingItem. Furthermore, the result XML from the CreateMultipartXMLbasedonFetchXML has to be added to the fieldMultiDocumentXML in the Advanced Section.
The top of the AutoMergeWorking Item will look like below.
Figure 4: AutoMergeWorkingItems
Step 5: Start your workflow
The result of your workflow will be visible in the CreatedDocument-field in the AutoMergeWorkingItems-window (please see figure 4).
Please note: You could as well combine this workflow with one that creates an eMail, attaches the here created document to an email, and sends the so created eMail to a certain group of people. Please read more about how to create such a workflow here.
That’s it! We appreciate your feedback! Please share your thoughts by sending an email to email@example.com!