To demonstrate the usage of a select parameters in a document which lists employee info for a specific employee.
Sometimes you need to generate a document, but you don’t need the same document for every single row in your database, you only need one row. So you can use filters to filter out a single row. But you don’t want to change the filter every single time you want to generate a similar document. That’s where parameters come in and in this tutorial, we teach you how to make a parameter that lets you select from your employees first names!
Start off with a template similar to the one in the picture below. It has the MSSQL datasource loaded into it (see Connecting to your SQL data if you don’t know what this means) as well as a query tag and some out tags (see Query Tag for more information on the Query Tag). It also has some custom styling, but that’s something that Word does with or without AutoTag.
The first step is to add a parameter as you did in Parameter Basics . Open the Parameters window from the AutoTag Manager ribbon, then click Add and name the parameter FirstName. We are using this parameter to select an employee’s first name. Something important to note is that parameters cannot start with numbers, and cannot contain spaces.
We want to be able to select a row of data using this parameter, so we’re going to select it’s type as select.
Click the small wizard icon next to the Select text box to open the SQL Wizard. We only need to make a basic selection here, so drag the Employees.FirstName column to the Columns box.
Select the query tag and open the wizard for it. We are treating the query tag here just like a forEach tag, except we only expect it to return one result. If it returns multiple results, only the first one will be displayed.
We need these four columns to make our document, so drag them into the columns box.
Now we’ll be adding a filter just like in SQL - Part 4: Filtering with Parameter Values . Add a group, then afilter, then set the node to Employees.FirstName and set the value to the parameter $(FirstName) from the drop-down box.
Close that wizard and select the data for each of the out tags using the usual data tree method. It should be fairly clear where each piece of data belongs, or you could mix it up for fun.
Generate the document using the usual means – output -> output format. Now for the extra step in document generation: inputting parameter values. You can type in the box like you have before, or you can use the drop down menu to select from a list of values retrieved from the database! The results reflect your choice.
You have completed this tutorial. We recommend taking a look at the Creating a POD tutorial next!