The "Generate Document" action is used to generate documents based on values in fields on the current item. This action can use one of the following:
▪Word template from document library. Columns in the current item can be mapped to merge fields in the Word template.
▪Excel template from document library. Columns in the current item can be mapped to merge fields in the Excel template.
▪"Item Template" that was created in the Print Manager app. (Columns in the current item are mapped when the Item Template is created.) This generates a Word doc or a PDF file.
In all of these cases, the document can be saved in a designated document library with a specific file name, or it can be added to the current item as an attachment. It also allows mapping between columns in the current item and meta-properties of the document in the document library. These features are explained below. Note: the person running this action needs to have permission to create/add a document in the specified Document Library.
Action Name: enter the name of the action
Execution Status: Whether to show or hide this Action in the screen that shows to the user when running this Custom Action. This does not affect whether it runs, only whether it shows to the user while running.
Conditions: set conditions that can restrict when this action runs. Conditions are not required.
Document Template: Choose Template Type -- either Microsoft Word, Microsoft Excel, or List Item Template
Microsoft Word or Microsoft Excel: select either of these to have the option to choose a Word or Excel template from a document library in the Site. These templates can be for any purpose, such as a contract, invoice, quote, purchase order, etc., depending on what the purpose of application is.
Most often, a document library is created specifically to hold one or more templates. The templates have to be created and uploaded beforehand. The templates are created with placeholders for the SharePoint list item data:
In Word, use the Merge Fields option (see image below) to put the fields where they should go in the template.
The "Merge Fields Mappings" in this Action is used to match the placeholders in the template with SharePoint list item columns.
Merge Fields Mappings: this is used when "Microsoft Word"or "Microsoft Excel" is chosen as the Template Type. The Column Mappings match the SharePoint item columns to the fields (placeholders) on the template. Add Column Mapping brings up the below screen, where the Merge Field (from the Word or Excel template) is chosen and then matched to a column from the SharePoint list. Further refinement of the value that is placed in the template can be done using the Functions option and the Value Format, if needed.
List Item Template: select this to have the option to choose a List Item Template. This uses the Item Templates that were created in the Print Manager app. The gear at the end of the row will open the Print Manager, where templates can be added or modified. The refresh (circular arrow) will re-populate the list with any new templates created in Print Manager.
Save Document In section
Save to: either a Document Library or an attachment on the Current Item
These three options show up only when "Document Library" is chosen:
Select Target Site URL: either a Site in the current Site Collection or a specific Site URL in the tenant or farm.
Library: the Document Library in the Site selected above
Folder Path Name: the folder path in the Library (optional)
File Name: enter in the file name of the document. Placeholders (variables) from the current item can be used in the file name, in the format of "%%[column|column]%%". For example, "PO_%%[ID|ID]%%_%%[Title|Title]%%". This would use the ID and Title from the current item in the file name, such as "PO_25_New Laptop Request".
For Microsoft Word templates, the file can be saved as a DOC or DOCX.
For Microsoft Excel templates, the file can be saved as a XLS or XLSX.
For List Item Templates, the file can be saved as a PDF or a Word Document.
Note that the file extension (.DOC, .DOCX, .XLS, .XLSX, or .PDF) is added to the document when it is created and should not be added in the File Name box.
Overwrite Existing File: choose whether to overwrite a file if it has the same file name.
Item Column Value Settings (optional): set properties for the document when it is saved in the document library. These values are the properties of the document (the meta-data) in the library, not fields or values in the actual document itself (those come from the Template). A document library contains the document, but each document can also have properties for meta-tagging, grouping, sorting, and other purposes.
There are two tabs here: "User input columns" and "Predefined column values".
User input columns -- user can enter values for the columns (properties) of this document in the document library when running the action. The box on the left is a list of the available columns. Drag columns to the right box to have them come up and ask for user input when running this action.
Predefined column values -- these set the values of the columns (properties) of this document in the document library based on mappings to fields on the SharePoint list item.
Add Column Mapping brings up this box, where the column on the document library is selected, and then the value is determined based on fields from the SharePoint list or Functions that modify that value.