To create links to locations in a document based on names retrieved from a datasource.
Start with the template created in the For-Each Tags tutorial, after finishing the extra-credit section.
We are inserting a page break before the table, at the very beginning of the document so that the first page is blank. This is where we will put our table of contents. There should now be three pages in your template: a blank page, a page with a table, and a page with an "End ForEach" tag.
Now we will add a "ForEach" tag where we are going to create a table of contents using Link tags. Bind it to the "customer" table in the "Data Tree" and add an "End ForEach" tag. It would be a great idea to give a nickname and variable name to the tag. Name the variable "customer."
Now we will add a link tag. The plan is to use the customer ID as the bookmark, which is what the link will point to. In Microsoft Word, bookmark names cannot start with numbers so we are going to pre-pend the bookmark with the text 'id'.
After adding the link tag, select the customer ID as the data, and then add 'id'+ to the beginning of the "select" string as shown in the video below. We do this because sometimes, ID columns are numbers. When using bookmarks, the value cannot start with a number, so we make it always start with "id." For a row where the ID is 200, the bookmark value is "id200". Finally, select the link "Type" as "bookmark." Don't forget an End Link tag!
We are going to add "out" tags that display the first and last name of the customer. This step should be familiar if you have done the inserting a tag tutorial.
Next is the bookmark tag. This is the anchor that the link tag will point to, so it's "value" field must be exactly the same. For this reason we'll select "customerID" as the data, and prepend " 'id'+ " to the value.
You have completed this tutorial. We recommend taking a look at the If-Else tags tutorial next!