Support for checkboxes in Word documents for Generate Document Action

Applies To: SharePoint Online

Description:

In SharePoint lists we have checkbox columns (multi-choice). Also, Yes/No column can be represented as a checkbox. If SharePoint list item form has checkboxes, sometimes similar UI is required in document (Word/pdf) that are generated based on that item. Checkboxes support in Word templates ensures that look and feel of generated document is closer to the item form. NITRO document generation now supports this feature. Based on values in SharePoint list item, checkboxes can be checked/unchecked in Word document template.

Summary of steps

1.      Enable checkboxes in Microsoft Word.

2.      Create SharePoint list with required columns (or use existing list/columns).

3.      Create a Word template with checkbox controls.

4.      Configure Generate document action.

5.      Map list item columns to checkbox controls in template.

6.      Run the action to generate document.

Enable checkboxes in Microsoft Word

Checkboxes can be added to Word document from the ‘Developer’ tab. By default, this tab is not visible in the ribbon of Microsoft Word. Please follow below steps to make it visible.

Open Microsoft Word and go to File -> Options -> Customize Ribbon.

In the Main Tabs section, enable ‘Developer’ tab.

After above step, Developer tab will be visible in Word:

In Developer tab, checkbox option is available. Move the cursor to the required position in the word document. After that click checkbox in the ribbon to insert it in the required position in the document. For settings of Checkbox, select the ‘Checkbox’ in the document and navigate to properties in ‘Controls’ group of ‘Developer’ Tab.

Create SharePoint list with required columns

In this article, we will take below examples to map to checkboxes in a word document. Based on values in the SharePoint list item for these columns, corresponding checkboxes will get checked/unchecked in the generated word document.

Columns in SharePoint List (Onboarding Request) for which checkboxes are created in MS Word template

  1. Single Choice
    1. Employee type
      1. Full-time
      2. Contractor
      1. Ad-hoc
  2. Multi-choice column
    1. Column name: Application Access
    2. Column internal name: ApplicationAccess
    • Choice options:
      1. SQL Server
      2. Active Directory
      3. Azure
      1. SharePoint
  3. Yes/No column
    1. Column name: Allow Administrator Access
    2. Column internal name: AllowAdministratorAccess
    3. Choice options: Yes/No

Text column

  • Column name: Employee Name

  • Column internal name: EmployeeName

Other columns in SharePoint List for which checkboxes are not created in MS Word template

  • Title column
    • Column name: Title
    • Column internal name: Title
  • Text Column
    • Column name: Employee Name
    • Column internal name: EmployeeName
  • Text Column
    • Column name: Cloud
    • Column internal name: Cloud
  • Text Column
    • Column name: Database
    • Column internal name: Database

Expressions

Expressions – String concatenate function is used in expression. Based on the output of this function corresponding checkbox will be checked/unchecked.

Create a Word template with checkbox controls

Checkbox can be single or part of a group with multiple related options.

This article will show implementation of checkboxes in the word template for above mentioned column examples

Insert a group of checkboxes for single choice column in template

To create above mentioned single Choice checkbox controls follow the below steps.

Step 1. In word document, type Employee Type as group name and create 3 checkboxes as shown below. These checkboxes are the allowable column values of which only a single value can be selected at a time.

Step 2: Go to Content Control properties of a check-box through Developer tab. In the pop-up provide as below:

  • Title: Values of each checkbox should match with possible value(s) of the column. Based on the values in column, corresponding checkbox(es) gets checked.
  • Tag: Each checkbox in the group should have same tag. Provide a name for the checkbox group, this will be visible in the Custom Action configuration dialog to map to the item column value(s).

Repeat Step 2 for all the checkboxes in this group.

Insert Checkbox for Multi choice column

To create above mentioned multi-Choice checkbox controls follow the below steps

Step 1. In word document, type Application Access as group name and create 4 checkboxes as shown below. These checkboxes are the allowable column values of which multi values can be selected at a time.

Step 2: Go to Content Control properties of a check-box through Developer tab. In the pop-up provide as below:

  • Title: Values of each checkbox should match with possible value(s) of the column. Based on the values in column, corresponding checkbox(es) gets checked.
  • Tag: Each checkbox in the group should have same tag. Provide a name for the checkbox group, this will be visible in the Custom Action configuration dialog to map to the item column value(s).

Repeat Step 2 for all the checkboxes in this group.

Insert checkboxes for Yes/No column in template

To create above mentioned Yes/No column checkbox controls follow the below steps

Step 1. In word document, type Allow Administrator Access as group name and create 2 checkboxes as shown below. These checkboxes are the allowable column values of which Yes/No values can be selected at a time.

Step 2: Go to Content Control properties of a check-box through Developer tab. In the pop-up provide as below

  • Title: Values of each checkbox should match with possible value(s) of the column. Based on the values in column, corresponding checkbox(es) gets checked.
  • Tag: Each checkbox in the group should have same tag. Provide a name for the checkbox group, this will be visible in the Custom Action configuration dialog to map to the item column value(s).

Repeat Step 2 for all the checkboxes in this group.

Insert a checkbox for Text column in template

Normally text columns will not be mapped to check boxes. However, if required this can be done. Checkbox will get checked in the generated document only if the value of text column in the item matches with the Title of the checkbox in the template. To create Text column based checkbox control follow the below steps.

Step 1. In word document, type EmployeeName (can be any name) as group name and create a checkbox as shown below.

Step 2: Go to Content Control properties of a check-box through Developer tab. In the pop-up provide as below

  • Title: This value should match with the item column value. Once matched, checkbox gets checked.
  • Tag: Provide a name for the control, this will be visible in the Custom Action configuration dialog to map to the item column value.

Note: Text column value can be directly inserted in the document. For this, add a ‘Merge fields Mappings’ and configure mapping for text column.

If required, a checkbox can be checked for a specific value in text column.

This checkbox will be checked only if the value in Text Column is ‘John Smith’. Otherwise, it will be unchecked.

Sample MS word Template

Configure Generate document action

Please refer to this document for configuring a MS Word template based document generation.

Content Control Mappings in Generate Document Action

In ‘Content Control Mappings’ field, Add Mappings for ‘Tag’ provided to checkboxes in Template.

Note: In Content Control Mappings, we can map either Column placeholder or values or expressions. Based on output of Column placeholder or values passed or expressions, corresponding checkbox will be checked/unchecked

Content control mapping for sample document:

  • Tag name provided to checkboxes in template will be visible in Content control mappings as shown below:

1.       Map List Item Columns to checkbox controls (Tag) in template

Below example shows the ‘Column Placeholder’ mappings:

Item for which document is generated with checkboxes shown below:

Run the action to generate document

Run ‘Generate Document’ Custom Action on above item. It will generate MS word document on location provided in the Custom Action.

Below document will be generated for above item:

1.       Map Expression (Strcat), value and variable to checkbox controls (Tag) in template

Output of expressions can be mapped to checkboxes as well. Checkbox will get checked in the generated document only if the output value of expression/placeholder matches with the Title of the checkbox in the template.

Below example shows the ‘Expression’ mapping in Content Control Mappings:

Item for which document is generated with checkboxes is shown below:

Run the action to generate document

Run ‘Generate document’ custom action on above item. Below shown document will be generated. Based on output of expression corresponding checkboxes get checked/unchecked in the document.