In August 2019 I published a post titled ‘Auto-populating document templates via a form in SharePoint‘. The suggested model was based on using a SharePoint 2010 workflow in SharePoint Designer.
In July 2020, Microsoft announced that it would turn off SharePoint 2010 workflows for newly created tenants from 1 August 2020, and would remove the ability to run or create these workflows from existing tenants from 1 November 2020. It recommended that organisations use Power Automate instead. (Source: Microsoft Ending Workflows for SharePoint 2010 Online Next Month).
This post details an alternative option, with no workflows required – but with the same set up – that may be sufficient in most cases. At this sage (September 2020), there does not appear to be an out of the box option with Power Automate that will create a document (from a content type) when a new document set is created.
The alternative option requires the following elements:
- The document set feature enabled.
- New site columns for each unique metadata required in the output documents.
- New document set and document content types, both with the same metadata.
- One or more Word document templates.
- A SPO site with a document library. It is recommended that a dedicated library (e.g., ‘Client Agreements’) is created for this purpose.
Note – the person who does this must be a Site Collection Administrator.
The main difference with the earlier model is that there is no workflow to create the document/s. Instead, the end user creates and saves (without modification except a name) the document into the library/document set where the custom metadata is stored. The method below then auto-populates those new documents with the required metadata.
This option does not use a separate list as the metadata details can be extracted from the document sets.
Enabling the document set feature
The document set feature must be enabled via Site Settings > Site Collection Administration > Site collection features. If you don’t see this option, you don’t have the required level of permission.
It may be a good idea to activate the Document ID Service at the same time as this can be a useful additional piece of metadata in the final documents.
New site columns
From the same Site Settings area, go to the Web Designer Galleries section to add the required new site columns. Directly below that option is where you create new site content types.
The Site Columns section has a very large number of default columns that come with every SPO site. Check to make sure the required columns don’t already exist, or are non-recommended column names (like ‘Library’).
Assuming the required columns do not exist, select the ‘Create’ option to create a new custom column. A couple of points to keep in mind here:
- Give the column a name that is obvious (easy to find).
- Don’t put spaces between words but capitalise each word (e.g., ‘ClientName’, ‘ClientAddress’). From experience, this space can cause the metadata element to wrap to a second line and cause problems.
- Keep in mind that the ‘Single line of text’ is free text. If you want controlled choices, use the Choice option instead.
- Date and Time may require some tweaking to get the correct format in the output Word document. It may be easier to use ‘Single line of text’ if some dates may vary or aren’t exact.
- Don’t use the ‘Yes/No’ option. Instead, use a Choice column with those options instead.
- Person or Group is only for internal names recorded in Active Directory (AD). If you need to insert any other name, use the single line of text.
The additional column settings that may be useful are:
- Require that this column contain information. If changed to ‘Yes’, this metadata field will be mandatory.
- Enforce unique values. Generally not used unless there is a requirement to enforce unique values (e.g., unique client IDs).
- Maximum number of characters. This can be useful to restrict the number of characters. For example, ‘Postcode’ will only have four characters. Don’t use the number field for postcodes.
- Default text. This option is useful if there is a requirement to have a default value, especially from a choice list, or if the value will usually always be the same (although that could also be simply added to the text of the document template.
- Column formatting. Don’t use this if the content is to be copied to a document template.
- Column validation. This may be useful to ensure that only certain characters are entered. For example, postcodes will never have a letter, only numbers.
Repeat this process until all the required metadata columns exist.
New document set content type
Create a document set content type so the output Word documents (and any other digital content) can be stored in the same ‘folder’.
To create a new document set content type, return to the Site Settings and, under Web Designer Galleries, select ‘Site content types’.
Give the new content type a name that is obvious for its purpose (e.g., ‘ClientAgreementsFolder’).
Importantly, change ‘Select parent content type from’ > Document Set Content Types, and ‘Parent Content Type’ > Document Set.
Open the content type that has been created. Under the ‘Columns’ section, add the columns ‘from existing site columns’. The example below shows a series of site columns that were added. Don’t remove any of the other columns.
In the above example. the ‘Title’ column is hidden (default setting). If you click this column, you will see the option under the ‘Change Content Type Column’ to make it required, optional or hidden. Generally, these settings should not be changed.
New Document Content Type
Now, create a new document content type. Give the content type a name that reflects its purpose. Ensure that ‘Select parent content type from’ is set to ‘Document Content Types’ and ‘Parent Content Type’ is set to ‘Document’ as shown below.
The next step is to add the two content types to a document library.
Adding the content types to a document library
All the steps below can be carried out by a Site Owner.
Open the library where the content types are to be added and go to Library Settings (via the Cog/Gear option). In the Library Settings, under ‘Advanced Settings’, click the option to ‘Allow management of content types’ (change from No to Yes).
If you don’t want other folders to be created in this library, change ‘Make ‘New Folder’ command available’ from Yes to No.
A new section will now appear in the Library Settings – ‘Content Types’.
To add the two content types that were created, click on ‘Add from existing site content types’, select each content type from the list that is displayed, and click OK.
The two content types should now appear in the list of Content Types and the custom site columns should appear in the ‘Columns’ list.
Click on the document set content type (e.g., ‘ClientAgreementsFolder’). The custom columns should be visible. Now, we need to share these columns with the custom document. Click on ‘Document Set Settings’.
- From the list of ‘Available Site Content Types’, chose the custom document content type that was created above. Ignore the ‘Document’ content type.
- In the ‘Shared Columns’ section, check the box against all the custom columns.
- Click OK.
The steps above will mean that all the custom columns in the document set will be shared with the the document content type. When you return to the Library Settings, you will see under the ‘Columns’ section that the columns are now shared with the two custom content types as well as the default Document content type (which can be ignored).
Add the Word template to the document content type
Now, add the Word template to the document content type. Note that this step is NOT done at the Site Content Types level, but at the local library level.
Ensure the Word document template is in the latest version of Word (e.g., docx) and has all the text required. It can be updated at any time (see below) but it is important to ensure that the document is as complete as possible, and the sections where the metadata is to be placed is obvious. One way to do this is to put text such as CLIENT NAME in the body of the document. Avoid using highlights as this can be troublesome (but not impossible) to remove.
From the Library Settings, Content Types section, click on the custom document content type (e.g., ‘ClientAgeements’). Click on Advanced settings.
Click ‘upload a new document template’ and add the document template. The name of the template should be obvious. It is possible to go back and edit the template at any time after it has been uploaded. This is usually much easier if a change is required, compared with uploading a new template and having to re-link all the metadata.
Connect the metadata to the document content
From the Document Template section above, click on ‘Edit Template’. This should open the document in the installed Word application. These steps cannot be carried out using Word Online.
Place the cursor in the body of the text where the metadata is to be placed. Click on the ‘Insert’ tab in Word, then click on ‘Quick Parts’ in the text section.
Click on ‘Document Property’ and the custom columns will appear.
When you select each property, the word document will display it as shown below. Continue this process until all the required metadata is added to the document:
As noted earlier, it is usually much easier to edit an existing template ‘in place’ instead of uploading a new version because the steps involved in adding the metadata to the template must be repeated if a new template is uploaded.
Auto-populating Word documents
Now that all the elements are in place, metadata is added automatically to the Word template as follows.
First, open the document library. Click on ‘+ New’ and choose the document set content type (e.g., Client Folder).
Fill in the metadata elements required, then click ‘Save’.
Now, open the document set/folder, and click on the document content type (e.g., ‘ClientAgreement’). This will open the Word template.
Don’t change the document, just click File – Save As. This should display the list of SharePoint sites on the right. Give the document a name, then choose the relevant site (e.g., ‘Client Agreements’), then the relevant library and document set/folder and press save. This is the most complicated part of the process once it is set up.
The template document, with all the metadata elements, should now appear in the document library under the document set/folder. As it is a Word document, it is possible to ask someone to sign on glass, then ‘save as’ a PDF.
If the document requires a sensitivity label and these are enabled, this can be added directly from the Word document menu when it is created.
Other relevant documents (e.g., emails) could be added to the same folder, including drag and drop from Outlook or other locations when the library is synced to File Explorer.
Note that the metadata elements that were added to the document in this way form part of properties of the document. These properties, which will remain with the document if it downloaded or attached to an email, can be viewed from the ‘File – Info’ section of the Word document.
The disabling of SharePoint 2010 workflows in SharePoint Designer has removed the ability to auto-create a document in SharePoint with the required metadata. However, it is not particularly difficult to set up a site, with two custom content types, one of which contains a document template, to achieve the same outcome without any workflow at all. The only complicating factor is the requirement to save the document template back to the library – without making any changes at all.