mscrm-addons.com - Blog

News.mscrm-addons.com Blog

rss

Hello and welcome to our blog! What can we do for you? Are you looking for further technical information or step-by-step instructions to our products? Or would you like to read the latest news on mscrm-addons? Please feel free to browse our blog for detailed information and to share our posts!


How do I create a document that includes all child records of a certain entity?

This article outlines how to set up a workflow that will generate a document which 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 DCPWorkflowSandobox:DCPCreateMultiPartXmlbassedonFetchxml step. 

Figure 1: Workflow Activities

Step 2: Set the properties for the DCPWorkflowSandobox:DCPCreateMultiPartXmlbassedonFetchxml step
With a click on the [Set Properties]-button you add your individual properties to the parameters:

The first three properties allow you 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.

Step 3: Create a FetchXML
We recommend you to use a
FetchXML builder if you want to create a new FetchXML, because it facilitates the creation of 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" />

      </filter>

    </link-entity>

  </entity>

</fetch>

Please note: 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. 

  • 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

Figure 2: Set Custom Step Input Properties

Step 4: Create an AutoMergeWorkingItem
As next step you need to create the AutoMergeWorkingItem. Furthermore, the result XML from the CreateMultipartXMLbasedonFetchXML has to be added to the field
MultiDocumentXML in the Advanced Section.

Figure 3: Set the MultiDocumentXML

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 support@mscrm-addons.com




Comments are closed.