Cloud for Good
Close this search box.

Streamline Your Merge Documents with Conditional Logic

Acknowledgment letters and other documents are key to making sure your donors and other supporters feel recognized. Whether it’s a thank you letter, an end-of-year tax receipt, or even a name badge at your annual gala, you want to make sure your constituents feel individually recognized. Of course, we have mail merge as a tool at our disposal to automatically generate such documents based on our Salesforce data. Whether you’re using the native mail merge function in Word from an exported Salesforce report, or a third-party Salesforce application such as Apsona, Nintex, or Conga, running a mail merge helps you generate many personalized documents all at once. But is there a way you can make your documents even more personalized, AND streamline your mail merge process? It may sound to good to be true, but the answer is ‘Yes!’… with conditional logic.

Building conditional logic into your merge templates will allow you to display different text based on criteria found in your Salesforce data. This means you can have entirely different messaging for different types of donors or other individuals without having to run separate merge operations with different templates and reports. There are many ways that you as a nonprofit professional might want to cater the language in merge documents to fit different types of donors. Here are just a few examples:

  • Geography – maybe you want to include different text in letters to donors based on where they live. Let’s say your organization does specific work in a donor’s region that you want them to know about. You can set up conditional logic based on a Salesforce field (such as their state) so that the letter merges to contain the text that you want them to see as a resident of that area.
  • New vs. repeat donor – if someone is donating for the first time, you probably want to say something different to them than you would to someone who has been supporting your organization for a long time. You can set up conditional logic to have different language in each thank-you letter, depending on whether it is the person’s first donation, or if they have donated before.
  • Amount of donation – every donation counts, but the language in your typical letter to a major donor with whom you have a deep relationship will probably be different from the one you’d send for a small donation received from a casual acquaintance of your organization. Use conditional logic to differentiate the messaging in these letters from the get-go, all based on data available in your Salesforce org.
  • Gift designation – if the gift has a restriction, you probably want to note that in the thank-you letter, so the donor knows that their contribution is going where they intended. Even if the designation is in Salesforce as an accounting code, you can set the criteria to insert an entire sentence that acknowledges how the gift has been designated, based on that code. And the sentence does not have to appear at all if there is no designation.

Of course, you could accomplish any of these tasks by creating a separate Salesforce report based on each donor characteristic, building a letter template for each group with the proper messaging, and running a mail merge operation for each type of letter. Or, you could run the mail merge, then read through each of the merged letters one by one (maybe a Ctrl+F here and there) and edit the language where needed. But these options sound repetitive and tedious, right? With conditional logic, save yourself time and frustration by creating one letter template that can be used with one mailing list, but still give you the tailored messaging you need in each of your letters.

How you do this for your specific use case will depend on your mail merge tool of choice, and how you’ve configured Salesforce and the Nonprofit Success Pack (NPSP) to store your data. But here are the steps to create a basic mail merge with conditional logic to accomplish our geography example above, using a recent version of Microsoft Word for Mac, a sample data export from Salesforce in .xlsx format, and the Mailing State field as the basis for our condition:

  1. Open a new Word document as usual when starting a new mail merge template.
  2. Open the data source under Mailings / Select Recipients / Use an Existing List. Select the spreadsheet you exported from Salesforce as the data source.
  3. Insert all of your Merge Fields as usual – including First Name, Last Name – whatever you need to appear in the letter for all recipients.
  4. Now, the fun starts! Navigate to the section of your letter where the text will change depending on the recipient’s location.
  5. Click on Rules (under Mailings) and select ‘If… Then… Else’
  6. Fill out the fields, including:
    • Off of which ‘Field name’ (or column) from your Salesforce data is the condition based? (In this case, it is Mailing State)
    • What value is it checking for, and what is the Comparison Type? (In this case, we are looking for Mailing State is Equal To ‘NY’, as our first criterion).
    • What text should be inserted if the above statement is true? (In this case, we’ve inserted the language that should only appear if Mailing State = ‘NY’).
    • What text should be inserted if the above statement is false? You can leave this blank if no text should appear, or if you need to define more possibilities in separate rules, as in this example.
  7. Repeat steps 5 and 6 for each geographic location.


The unmerged document should look something like this, with all of your merge fields, plus one of your conditional statements previewed.


The other rules you’ve set are also there, but may be hidden until you preview or merge the documents with actual data.

Now when we merge the document (Finish & Merge), we have two distinct letters with a different second paragraph for each of our two recipients, all done with just one Salesforce report and one Word template!


This is just one small example of how you can use conditional logic in merge templates to save time generating dynamic and ultra-personalized thank you letters and other documents, all from data in your Salesforce org. If you use a third-party application to do mail merges, be sure to check out the vendor’s documentation for how to do conditional logic with their application.

You may also be interested in reading: