Document Generator introduction

Document created by Andreas_Meier Employee on Sep 6, 2017Last modified by Matthias_Walter on Jun 26, 2018
Version 7Show Document
  • View in full screen mode

Table of contents

What is Document Generator

 

"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 Action Links or Rich Forms buttons.

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

 

Main advantages:

  • Word Document is generated on a fully customizable template
  • Creating a template is as simple as writing a word document and can be done by power users
  • Metadata of a single item, a list or even connected sublists with all their data can be added into this document
  • Report across a dossier (master-slave relation) can be created

 

The Document Generator feature provides the ability to generate different types of documents, such as:

  • Invoice
  • Factsheet
  • Project Report
  • Correspondence
  • Work Report
  • Order Confirmation
  • Inventory List
  • ... and many more

 

Configuration UI

A new action type is introduced in the Action Builder of Action Links and Rich Forms.

 

Configuration for a single item (example: Action Link on a Display Form):

   Document Generator Action Link configuration

Configuration for multiple items (example: Action Link on a View):

 

Description of the configuration parameters:

 

  • Template
    • Provided Word Template that contains placeholders can be uploaded here (templates are stored in a hidden library "sbDocumentGenerator")
      The current used template can be downloaded by clicking on the “Current template” link.
  • Data
    • Choice: “For single item” / “For multiple items”
    • List: list from current site
    • Item ID (only if “For single item” selected): ID or expression to be evaluated as ID of the item we want to have as context in the document
    • List Query (only if “For multiple items” selected): CAML query used to filter list item
    • List View (only if “For multiple items” selected): defined filters in list views are merged with the query above
  • Target
    • Choice: “Save to library” / “Open in browser”
    • Library (only if “Save to library” selected): target document library, where the generated document should be stored
    • Subfolder (only if “Save to library” selected): fixed subfolder path or dynamically calculated using an expression e.g. with placeholders
    • Filename: file name for generated document. fixed name or dynamically calculated using an expression e.g. with placeholders
    • Overwrite Existing File (only if “Save to library” selected): if checked and the file is already stored in the configured library, the old file will be overwritten.

 

Document Templates

Supported template format is docx. The template is created in Microsoft Word or other software that support the docx format.
Currently skybow Document Generator allows inserting skybow placeholders, conditions, loops, nested loops and loops over table rows.

In the next versions also insertion of images will be possible.

Example of a template (download)

   Document Generator Word template

 

You can check out this template and play around by starting from our Timesheet Management Template or simply download it from here.

Find the generate link on the "Work hours for week" dossier display form:

 

Example of generated document

   Document Generator - Example of generated document

 

Word Generator Placeholder Expressions

You can use different kinds of expressions to show the metadata in a word document.

Expression syntax

Template expressionsAny kind of string Template Expression[[Title]] [[Firstname]]
Assignment ExpressionsStart with "[[=" and any kind of string Expression[[= [[Title]] + ", " + [[Firstname]] ]]
Function Code ExpressionsStart with "[[{" in the Tag property. Write your complex expression as content in the placeholder[[{ var arr  = [[@Loop('Invoice', {return [[Total]];} )]]; var sum = 0; arr.forEach(n=>sum +=n); return sum; }]]
If Conditions

Start with [[if …]] and any kind of boolean Expression (Condition).
Ends with [[end if]]

 

Everything between the starting and the endig tag will be visible if the condition is true. This can be a text, an image etc.

[[if [[Budget]] > [[Outgoings]] ]]

[[Title]]

[[end if]]

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

[[if {return ([[Budget]] > [[Outgoings]]);} ]]

[[Title]]

[[end if]]

Loops

Start with [[loop]] for looping over multiple items of selected list.

If CAML Query is configured for this action link, looping will be filtered according to it.


Start with [[loop SublistTitle]] for looping over the sublist items filtered by lookup to the parent list.
If list that is not a sublist is selected (doesn’t have lookup to the list selected in action link configuration), no filtering will be applied.


Iteration ends with [[end loop]]

[[loop]]

[[Title]]

[[end loop]]

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

[[loop SubListTitle]]

[[Title]]

[[Firstname]]

[[end loop]]

Filtered Loops

Where 'SomeView' is a view .aspx page title:

The order and filter of the view are applied. If CAML query is added (optional), it is united with view query using an 'and' operator.

[[loop SublistTitle view('SomeView') query('<Where><BeginsWith><FieldRef Name="Title" /><Value Type="Text">[[{return [[Title]];}]]</Value></BeginsWith></Where>')]]

[[Title]]

[[end loop]]

Loops over documents in sublibraries

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

[[loop SublibraryName query('<View Scope="Recursive"></View>')]]

[[FileLeafRef]]

[[Title]]

[[OtherField]]

[[end loop]]

Nested LoopsLooping over sublist inside of the loop over multiple items of parent list is supported.
Looping over several sublists, or sublist of sublist are supported as well.

[[loop]]

[[Title]]

[[loop SubList1]]

[[Title]]

[[Firstname]]

[[end loop]]

[[loop SubList2]]

[[Title]]

[[Firstname]]

[[end loop]]

[[end loop]]

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

[[loop]]

[[Title]]

[[loop SubList]]

[[Title]]

[[Firstname]]

[[loop SublistOfSublist]]

[[Title]]

[[end loop]]

[[end loop]]

[[end loop]]

Loops over table rows

It is possible to loop over table rows by adding the loop inside the table.

 

In case of nested loops, if loop on parent list is placed into the external table, this will render separate table for each parent item

[[loop

SubListTitle]]

[[Title]]

[[Firstname]]

[[Lastname]]

[[end loop]]

 

[[loop]] [[Title]]

[[loop

SubListTitle]]

[[Title]]

[[Firstname]]

[[Lastname]]

[[end loop]]

[[end loop]]

Image

Show an image inside the document

 

You can optionally specify the width and height of the image

[[image ([[Picture]], [[Width]], [[Height]])]]

 

Without width and height:

[[image ([[Picture]])]]

 

Static width and height numbers used:

[[image ([[Picture]], 50, 50)]]

 

Static width number used:

[[image ([[Picture]], 300)]]

 

Static width number used:

[[image ([[Pic]], 20)]]

 

Static height number used:

[[image ([[Pic]],,150)]]

Placeholders usage details

The following placeholders from the Expression builder can be used in the word template:

  • Form Fields placeholders (except of [[..IsChanged]] and [[..OriginalValue]]
  • Web placeholders, including functions for filtering with CAML Query
  • Site placeholders, including functions for filtering with CAML Query

Not supported for usage in document generation:

  • Form Fields [[..IsChanged]] and [[..OriginalValue]] placeholders
  • User placeholders
  • Form placeholders
  • Page placeholders
  • Sublist placeholders

4 people found this helpful

Attachments

    Outcomes