# Add Titles to Documents

IDOL documents have a field named `DRETITLE` that can contain a title for the document. Front end applications might use the value of this field to present a title to users when displaying query results.

You should not rely on a connector to add a document title, because the connector might not be able to obtain this information. A suitable title for an e-mail message could be the subject of the e-mail, but this is not extracted until the e-mail is processed by CFS.

You can therefore use a Lua script to add a title to documents that do not have one, and, if necessary, ensure that all documents have suitable titles.

CFS includes a Lua script that adds titles to documents. The script is named `ExtractDreTitles.lua`, and is located in the `scripts` folder, in the CFS installation directory. You can use this script or modify it to suit your requirements.

The unmodified script ensures that all documents have a title. If a title has already been added to the document, that title is respected. If the document does not have a title, the script attempts to extract one from metadata fields that are added by KeyView and often contain titles. If none of these fields are present, the script adds a title by extracting the original file name from the field `DREORIGINALNAME`.

To add titles to documents using the `ExtractDreTitles` Lua script

1. Open the CFS configuration file.
2. Find the `[ImportTasks]` section of the configuration file, or create this section if it does not exist.

3. In the `[ImportTasks]` section, configure a `Post` import task to run the Lua script `scripts/ExtractDreTitles.Lua`.

   For example:

       [ImportTasks]
       Post0=Lua:scripts/ExtractDreTitles.lua

   TIP: You must use a `Post` task so that the script runs after KeyView filtering.

4. Save and close the configuration file.

_FT_HTML5_bannerTitle.htm