Advanced Concepts of Draw Loop

In draw loop we can merge the Salesforce record fields related to only the main object where we created DDP (Dynamic Document Package). To resolve this issue, we can use SOQL query in draw loop to fetch unrelated record or all child records.

In this article, we are going to see some advanced concepts of the Draw Loop with Salesforce integration.

  1. SOQL query in draw loop:

Generally, in draw loop we can merge the Salesforce record fields related to only the main object where we created DDP (Dynamic Document Package). To resolve this issue, we can use SOQL query in draw loop to fetch unrelated record or all child records.

Steps to create SOQL query: 

  1. Once the DDP record is created in Salesforce, click the ‘New Relationship’ button in the relationship section.
  1. Select Type as SOQL Query and write the SOQL query as to which record you want to fetch in SQOL field. Select Copy Type as row if you want to display list of records. Give any name to Relationship Alias to refer in field tagger.
  1. In Field tagger, we can refer the field which is returned by the SOQL query; so, click Field tagger in DDP record.
  1. Here, we can select the fields we want to merge in the document and place that tag to word document.
  1. To display records in table:
  2. Create a table in word document to display list of Salesforce record as shown below:
  1. Just two rows are enough to display all records dynamically based on the SOQL Query. One for displaying the title for the column and another for displaying records dynamically. In field tagger, there is a tag available as below. <<Parentguardians_Start>>, <<Parentguardians_name>>, <<Parentguardians_Type>>.
  2. These tags will have prefix with the field name we queried by SOQL. That prefix is taken from the name we used while creating the relationship record in the SOQL query in the field of Relationship Alias.
  3. The table size will be increased dynamically based on the number of records returned by the query. We don’t need to worry about the size of table.
  4. Dynamic image in word document:

We can display the Salesforce record image in a word document dynamically by using draw loop. The image should be public site URL in the Salesforce record field.

  1. Add a Rich Text field to an object
  2. Add an image to a record
  3. Configure the template
  4. Generate documents
  5. We need to create the rich text filed in Salesforce object to store the image in the record. After creating the field, add the image to the Salesforce record. In the Salesforce side, we have done the process to display the image. Now, we need to configure the template (Word Document) used in the draw loop to generate the dynamic document.
  6. Create the place holder in the word document to display the image and add sample image to the template. This image will be replaced by the Salesforce record image dynamically. The draw loop will automatically resize the place holder based on the image from the Salesforce record.
  1. In selection area, double-click the reference to the placeholder image, paste the tag from your clipboard, then edit the tag to include __image inside the angle brackets.

   For example 






Using Draw Loop, we can use SOQL query to fetch all child records as well as un related records to display in word document dynamically. We can use a table to display list of Salesforce record in table and can display the image dynamically.

Reference Link:

About MST

At MST Solutions our cornerstone is to adapt, engage and create solutions which guarantee the success of our clients. The talent of our team and experiences in varied business verticals gives us an advantage over other competitors.

Recent Articles

Work with us.

Our people aren’t just employees, they are key to the success of our business. We recognize the strengths of each individual and allow them time and resources to further develop those skills, crafting a culture of leaders who are passionate about where they are going within our organization.