Introduction to Document Generator

Introduction to Document Generator

What is the document generator?

The "Document Generator" allows you to generate documents based on a standard Microsoft Word file filled with SharePoint list data.

This can be triggered in actions used in list actions, modern forms or background actions (planned or triggered).

The generated document can either be downloaded directly from the browser or saved in a SharePoint library.

Main advantages:

  • Word document is created on the basis of a fully customizable template
  • Creating a template is as easy as writing a Word document and can be done by power users
  • Metadata of a single element, list or even related sublists with all their data can be inserted into this document
  • Reports on a dossier (master slave relationship) can be created

The Document Generator function provides the possibility to create different types of documents, e.g. B:

  • Invoicing
  • Leaflet
  • Project report
  • Correspondence
  • Work Report
  • Order confirmation
  • Inventory list
  • ... and many more

Configuration UI

Configuration for a single element (example: command bar action in a form):



Configuration for multiple elements (example: list action in one view):


Description ofConfiguration parameters:

  • Template
    • Provided Word template containing wildcards can be uploaded here (templates are saved in a hidden library "sbDocumentGenerator")
    • The currently used template can be downloaded by clicking on the link "Current Template".
  • Data protection
    • Selection: "For individual items" / "For multiple items"
    • List: List of current page
    • Item ID (only if "For single item": ID or expression to be evaluated as the ID of the article that we want to have as a context in the document
    • List query (only if "For multiple items" was selected): CAML query used to filter list elements
    • List view (only if "For multiple elements" is selected): defined filters in list views are merged with the above query
  • Target
    • Selection: "Save to library" / "Open in browser"
    • Library (only when selecting Save to Library): Target document library where the generated document is to be saved
    • Subfolders (only if "Save to Library" is selected): fixed subfolder path or dynamically calculated by an expression e.g. with placeholders
    • Filename: Filename for the generated document. Fixed name or dynamically calculated using an expression, e.g. B. with placeholders
    • Overwrite existing file (only if "Save to Library" is selected): If this option is enabled and the file is already saved in the configured library, the old file is overwritten.

Document templates

The supported template format is docx. The template is created in Microsoft Word or any other software that supports docx format.

Currently skybow Document Generator allows inserting skybow placeholders, conditions, loops, nested loops and loops via table lines.

In the next versions, inserting images will also be possible.

Example of a template



You can find the link "Generate" on the form "Working hours for the week", which shows the dossier:



Example of a generated document:



Word Generator Placeholder

You can use different types of expressions to display the metadata in a Word document.

Syntax

Templates ExpressionsAny strings[[Title]] [[First name]]
Assignments ExpressionsStart with "[[=" and any string[[= [[Title]] + ", " + [[First name]]]]
Function Code Expressions
Start with "[[[{" in the Tag property. Write your complex expression as content in the placeholder
[[{ var arr = [[@Web.GetValuesForQuery('OtherList', '', 'Total')]]; var sum = 0; arr.forEach(n=>sum +=n); return sum; }]]]]
Check ValuesUse [[Lookup.FieldInternalName]] to get any value from the target list of a lookup

*Does not work in scheduled and triggered actions

[[Department.Code]]*

[[Department.Author]]*

-------------------------------------------------------------

[[Department.Key]] -> to get the item ID of the department

If (if) conditions

Start with [[if …]] and any Boolean expression (condition).
End with [[end if]]]

Everything between the start and end tag is visible when the condition is met. This can be a text, image, etc.

[[if [[budget]] > [[outgoings]]]]

[[Title]]

[[end if]]

-------------------------------------------------------------

[[if {return ([[budget]]]]

[[Title]]

[[end if]]

-------------------------------------------------------------

[[if [[Status]]!="Completed" ]]]

[[Title]]

[[end if]]

Loops (grinding)

Start with [[loop]] to drag a loop over multiple elements of the selected list.

If CAML Query is configured for this action link, the loop is filtered afterwards.

Start with [[loop SublistTitle]] to drag a loop over the elements of the sublist filtered by looking up in the parent list.

Use the filterlookupfield('filed_internal_name') parameter to specify which lookup field should be used for the sublist if there are multiple lookups for the same list. It is optional if there is only one reference field.

RowLimit is also firmly encoded for 200 elements for query, but the required number can be specified with the optional parameter rowlimit(number).

If a list that is not a sublist is selected (no reference option to the list selected in the action link configuration), no filtering is applied.

Iteration ends with [[end loop]]

[[loop]]

[[Title]]

[[end loop]]

-------------------------------------------------------------

[[loop SubListTitle filterlookupfield('filed_internal_name') rowlimit(number)]]

[[Title]]

[[First name]]

[[end loop]]

Filtered Loops

'SomeView' is the title of a .aspx view page:

The order and filter of the view are applied. When a CAML query is added (optional), it is connected to the query of the view by a 'and' operator.

[[loop SublistTitle view('SomeView') query('[[{return [[Title]];}]')]]]]]]]]]]]]]]]]]]]]]]

[[Title]]

[[end loop]]

Loops about documents in sublibraries

Use the Scope="Recursive" property in the query to get documents in a folder when used as a sublibrary of a dossier.

Combine recursive range and filters in the CAML query to filter the metadata of the listed documents.

[[loop SublibraryName query('')]]

[[FileLeafRef]]

[[Title]]

[[OtherField]]

[[end loop]]

-------------------------------------------------------------

[[loop SublibraryName query('1')]]]

[[FileLeafRef]]

[[Title]]

[[OtherField]]

[[end loop]]

Nested loops

A loop over a sublist within the loop over several elements of the parent list is supported.

Grinding over multiple sublists or sublists of sublists is also supported.

If the wildcard [[@Loop.Parent.Firstname]]] is used, the data of the rear loop can be retrieved within the nested loop. Possible formats:

[[@Loop.Parent.Field1]]
[[@Loop.Parent.LookupField1.Field2]]
[[@Loop.Parent.Parent.Field3]]
[[@Loop.CurrentIndex]]
[[@Loop.Count]]]

[[loop]]

[[Title]]

[[loop SubList1]]

[[Title]]

[[First name]]

[[end loop]]

[[loop SubList2]]

[[Title]]

[[First name]]

[[end loop]]

[[end loop]]

-------------------------------------------------------------

[[loop]]

[[Title]]

[[loop SubListTitle]]

[[Title]]

[[First name]]

[[loop SublistTitleOfSublist]]]

[[Title]]

[[@Loop.Parent.Firstname]]

[[end loop]]

[[end loop]]

[[end loop]]

Loops in tables

It is possible to drag loops over table rows by inserting the loop inside the table.

If the loop is inserted into the external table via the parent list, a separate table is created for each parent element.


[[loop

SubListTitle]]

[[Title]]

[[First name]]

[[last name]]

[[end loop]]

[[loop]] [[Title]]

[[loop

SubListTitle]]

[[Title]]

[[First name]]

[[last name]]

[[end loop]]

[[end loop]]

Image

Show an image within the document

You can optionally specify the static width and height of the image as well as the maximum and minimum width and height.

The parameters width/height are not mandatory and can be specified as an empty string '' or zero.

Note: The wildcard [[picture...]] only works with images on the current site for planned and triggered actions



[[image]], width, height, maxwidth, maxheight, minwidth, minheight]]]

Without width and height:

[[image]]]

Static width and height numbers used:

[[image]]]

Static width number used:

[[image ([[Picture]], 20)]]

Static height number used:

[[image ([[Picture]],,150)]]

[[image]], '', '', '', '', 100, 300)]]

[[image ([[Picture]], maxwidth=100, maxheight=300)]]

[[image (url=[[[Picture]], maxwidth=100, maxheight=300)]]

LinkedIn

Create a link in the document

[[link]]]


[[link ([[Hyperlink.Url]], [[Hyperlink.Description]]]]]


[[link (url=[[Hyperlink.Url]], text='linktext')]]


Details about using placeholders

The following wildcards from Expression Builder can be used in the Word template:

  • Form field placeholders (except [[..IsChanged]] and [[..OriginalValue]]]
  • Web placeholders, including filtering features with CAML Query
  • Site placeholders, including functions for filtering with CAML Query
  • Output of variables and actions ([[@Variables..]] and [[@Actions..])



Not supported for use in document creation:

  • Form fields [[..IsChanged]] and [[..OriginalValue]] Placeholders
  • Form placeholder
  • Functions Placeholder
  • Side place holder
  • User placeholder
  • Sublist placeholders


    • Related Articles

    • Action: Generate document

      Generate document action allows you to generate documents based on a standard Microsoft Word file filled with SharePoint list data. For more information about Action Builder read Action Builder Introduction article. For more information about ...
    • How to handle the lookup columns threshold in a Document Generator template for a single item

      f your Document Generator Template contains more than 12 lookups that exceeds the SharePoint lookup column threshold, you may face the situation that the generated document may not include all lookup values. To overcome this problem we propose the ...
    • How to use QR code image in the Document Generator template

      There are a lot of services that generate QR codes. In this article, we use this service to generate QR code image with Send HTTP request action and use this image in the Document Generator template: 1. Add Send HTTP request action with the API ...
    • Action Builder Introduction

      The Teamsware Studio Action Builder is a tool that allows you to specify actions which are executed in consecutive order. You can build powerful workflows triggered from a form button, on form load, from a list view, scheduled or event triggered on a ...
    • Teamsware Studio Update 12.10.2023

      Bug fixes & improvements Modern Forms Version 1.3.35 Supported 'Opening Documents in the Browser' setting for sublibrary Added [[@Loop.CurrentIndex]] and [[@Loop.Count]] placeholders to Document generator template Fixed order of ...