With the skybow Document Generator you are able to create Microsoft Word Documents form SharePoint list items. The documents can be individually configured and designed. To do this, you first need a finished Microsoft Word document that serves as a template for the Document Generator Action.
This Microsoft Word document must contain the columns whose information is to be automatically inserted into the document later as placeholders. Once this has been completed, you can upload the Microsoft Word document using the Document Generator custom action.
How to create your template
- Create a new Microsoft Word Document.
- Style the document to resemble the look and feel for your organization’s requirements.
- Reference the fields on your SharePoint list form using square brackets around the field name. e.g. [[Title]]. (Remember to use the programmatic name and not the display name. This can be found at "Things in the background" and then "Columns".)
- Save your Microsoft Word Document.
How to create the Document Generator Action
It is recommended to use the Document Generator for a saved list item. Therefore if you are using a NewForm to create New Items, the first action would need to be ‘Save Form’. If you are using the EditForm or DisplayForm, you don’t need to use a Save Form action before the Generate Document action.
To create the Document Generation action you need to
- Choose "Actions" in the skybow command bar and then click on "Command Bar" to add a new action button to the top of your form.
- Click the "+" icon in the Command Bar Actions side panel.
- Provide a display name.
- Set an icon for your custom command bar button.
- Click "Configure Actions".
- Select "Generate Document" from the list of action types.
- Upload your saved Microsoft Word Document as a Template.
- Select at "Data Source" "For single item".
- Select your SharePoint List (just the main list, not the sub list).
- Set the Item ID field to [[ID]].
- Leave the default "Target" to "Open in Browser".
- Set the filename pattern for your reports. e.g. "Candidate-Summary-[[Title]]".
- Click on "Save".
You can now test your Command Bar action by opening or editing an item within your list.
Document Generator Microsoft Word Document Syntax
Template expressions | Any kind of string Template Expression | [[Title]] [[Firstname]] |
Assignment Expressions | Start with "[[=" and any kind of string Expression |
[[= [[Title]] + ", " + [[Firstname]] ]] |
Function Code Expressions | Start with "[[{" in the Tag property. Write your complex expression as content in the placeholder |
[[{ var arr = [[@Web.GetValuesForQuery('OtherList', '<View></View>', 'Total')]]; var sum = 0; arr.forEach(n=>sum +=n); return sum; }]] |
Lookup Values |
Use the *doesn't work in Scheduled & Triggered actions |
Examples:[[Department.Code]]* -> to get the item ID of the department
|
If Conditions |
Start with [[if …]] and any kind of boolean Expression (Condition).Ends with [[end if]] Everything between the starting and the ending tag will be visible if the condition is true. This can be text, an image etc. |
[[if [[Budget]] > [[Outgoings]] ]] |
Loops |
Start with [[loop]] for looping over multiple items of the selected list.If a 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. Use the filterlookupfield('field_internal_name') param to specify which lookup field to use for sublist in a case when several lookups on the same list exist. It’s optional where there is just one lookup field. Also RowLimit is hardcoded for 200 items for query, but the required number can be specified with the optional rowlimit(number) param.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]] |
Filtered Loops |
Where SomeView is a view .aspx page title, such as AllItems. The order and filter of the view are applied. If CAML query is added (optional), it is united with the view query using an ‘and’ operator. |
[[loop SublistTitle view('SomeView') query('<Where><BeginsWith><FieldRef Name="Title" /><Value Type="Text">[[{return [[Title]];}]]</Value></BeginsWith></Where>')]] |
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 form. Combine recursive scope and filter in CAML query to filter the listed document’s metadata. |
[[loop SublibraryName query('<View Scope="Recursive"></View>')]] |
Nested Loops |
Looping over a sublist inside of the loop over multiple items of the parent list is supported. Looping over several sublists, or a sublist of a sublist are supported as well. |
It is possible to loop over table rows by adding the loop inside the table. In the case of nested loops, if loop on parent list is placed into the external table, this will render separate table for each parent item |
Loops over table rows | It is possible to loop over table rows by adding the loop inside the table. In the case of nested loops, if the loop on the parent list is placed into the external table, this will render a separate table for each parent item | [[loop |
Image |
Show an image inside the document. Note: [[image...]] placeholder works only with images on current Site for Scheduled & Triggered actions |
[[image ([[Picture]], width, height, maxwidth, maxheight, minwidth, minheight)]] |
Link | Create a link in the document | [[link ([[Hyperlink]])]] |