Using Conditional Controls in ACT! Templates

Copied with permission from Linda Keating of JL Technical

[Note: This article is for a very advanced user. This is a great concept, but it may take a bit of trial and error on your part to get it to work properly. If you don’t have a good understanding of how Word’s Field Codes work you may want to invite an ACT! Certified Consultant to help you with this.]

How often have you had this thought: Wouldn’t it be great if I could use the same template to print letters that inserted custom text in the letter depending upon the value that appeared in an ACT! field. This would spare you the need of performing repetitive look-ups and mail merges.

If you set up your ACT! Word template properly, you can! Here’s an example.

A Sample Application

Let’s say you are running a fund-raising campaign and wanted to send out different letters to your individual and corporate donors. A third letter would go to your volunteers. You could perform three separate lookups and then print a separate letter to the individuals, the corporations, and the volunteers.

But here’s an easier way: Create an ACT! field called Donor Types and categorize each contact. Then perform a mail merge and let Word select which letter goes to each contact based upon the value in the Donor Type field.

This is how you set up your template so you’ll be able to print all three types of letters during a single mail merge.

Setting Up ACT!

First, you’ll need to create a new ACT! field or rename a User field to Donor Type. Then you must tag each record as either Individual, Corporation, or Volunteer.

ACT!Tip: To add the fields to the ACT! database, select Edit, Define Fields, and click the New Field button. You can also rename any of the User 1-15 fields if you are not using them for other data.

Remember: Once you’ve added new fields to your ACT! database, you need to add them to your layout in order to view them. You open ACT!’s Layout Editor by selecting Tools, Design Layouts. If you haven’t customized your ACT! layout yet, you should review the ACT! documentation.


Create the Custom Insert Text

Next you need to create the Word document files that contain the text for each of the letter types. It should be formatted as you want it printed. For this article I’ve used files named Example1.doc, Example2.doc, and Example3.doc.

WordTip: If the text is short, you can insert the text directly into the conditional command. I have found it easier to maintain separate files.


Create a Template

The third step is to design a basic template. You can create a new template by selecting File, New from the ACT! menu and then Microsoft Word – Template.

ACT!Tip: You can also start with a template you’ve already customized for things such as margins, headers, footers, and so on. This is done by selecting Write, Edit Document Template. Don’t forget to do a File, Save As before making your modifications.

Insert the Condition Controls

When entering control statements, you need to have the Word options set so you can see the Field Codes. You do this by selecting Tools, Options and then selecting the Show Field Codes option on the View tab. (You can also press Alt+F9 to Show/Hide Word’s Field Codes.)

This is how you insert Word fields:

1. Place your cursor at the position where you want to insert the conditional statements. From the Word menu select Insert, Field. The Field box appears. From the Field Names column select IF and uncheck the Preserve Formatting During Updates option. Select OK and return to your template. You should now see {IF } on your screen.

2. Place your cursor one space after the IF and enter a pair of quotation marks ("").

3. Place your cursor between the quotation marks and enter the ACT! field from ACT!’s Mail Merge Fields box. In this example it’s the Donor Type field.

4. Now insert an equal sign (=) and type "VOLUNTEER". (Note the quotes.) The expression should now look like this:
{IF "[[Donor Type]]"="Volunteer" }.

5. Place your cursor to the right of "Volunteer" and select Insert, Field and then select INCLUDETEXT from the Field Names list. Uncheck the box "Preserve Formatting During Updates" and click OK. (This tells Word what to do if the condition is True or False. The action in the first string will occur if the condition is True, otherwise the second string is used. In this example we’re going to insert text from a file.

6. Enter the path for your file — "C:\\act\document\\Example1.doc" — one space to the left of the INCLUDETEXT statement and enclose it in quotes. NOTE: the path must have double back-slashes.

7. The final step is to put a double quote ("") between the right french bracket that closes the INCLUDETEXT statement and the right french bracket that closes the IF statement. These quotes tell Word to do nothing if there is no match.

WordTip: Copy and paste this expression into the template, change the condition text and insert document name to create the rest of the choices.

After you’ve completed the template and you’re satisfied, you need to turn off the Show Field Codes option by select Tools, Options from Word’s menu, or press Alt+F9. 

Merging Your Letters

To perform the mail merge you must first perform a lookup to locate all the donors that you want to send the letter to. Select Write, Mail Merge and select your template. Select the send output to Printer option (this is a MUST).

ACT!Tip: If you select the Send Output to Word Processor when you are
generating the Mail Merge from ACT!, the conditional statements will not work after the first page. To test the template, you should select a small sample and print directly to the printer.)

Things To Watch For

Because ACT! inserts the text from the database and formats it as you have specified with the Edit, Define Field settings, you need to be certain to specify Word’s compare options properly.

For example, Word allows you to force all text to upper case for the purpose of comparing. There are other options for dealing with numeric comparisons. You should refer to Word’s manual or Help instructions for these settings.

Some Other Things You Can Do

Here are some additional ways you can use Word’s conditional statements:

  • If the company address is empty, than the mailing will go to the home address.
  • If the quantity is 500 or greater an additional discount of 5 percent is offered, otherwise the standard discount applies.
  • Replace the True/False field from a check box with ticked or unticked checkboxes
Technorati Tags: ,,,