3 Replies Latest reply on May 10, 2011 4:20 AM by Haakenlid

    Data merge with conditional text


      I'm new to InDesign scripting. Very new, in fact. I'm willing to learn, but my main motivation at present is to solve a particular issue. Surely this issue has come up before. I'd love to know if anybody has encountered it or if it is possible to accomplish through scripting.


      I want to merge data onto a gift pledge card. The exact text on the gift card will depend on the data being imported. For example, somebody who has given in the past will receive a message such as, "Thank you for your gift of $xxx." However, a person who has NOT given into the past will receive the message, "Please consider giving this year." The condition is the field prior_gift. If it's above 0, then the first message is displayed.


      This seems like a natural use for scripting, but, in my searches so far, I've found no references to using conditional text and data merges together in scripting. So, would this be a relatively simple task to accomplish?


      Thanks for any help you can give!

        • 1. Re: Data merge with conditional text
          John Hawkinson Level 5

          It would be a lot easier to just use a spreadsheet function in your input. =IF(A1=0,"Not given","Gave "&A1&" dollars") or whatever.

          • 2. Re: Data merge with conditional text
            Colin Flashman Adobe Community Professional

            the data merge feature with indesign only brings in text which was in the original data file itself - it doesn't know how to parse or interpret it to behave differently upon seeing certain results. that is, it doesn't run database queries such as if-else statements - it will only import text which was originally in the data file.


            however, there are plug-ins to indesign that CAN do this but they cost BOATLOADS. are you printing this yourself or are you sending this to a commercial printer? if the latter, have you discussed your print solution with the printer, as they may have a plug-in that can do this type of data merging, and all you would have to do is provide the printer with a packaged native file, along with the data and instructions as to what has to change... and for goodness sake see a proof of it!!!

            • 3. Re: Data merge with conditional text
              Haakenlid Level 3

              You can do this with a simple search and replace. It can be scripted, if you do this often.


              You can data merge the sum as "GIFT:500" or whatever and then use search and replace to replace any "GIFT:0" with "Please consider giving this year." . Then use GREP search to replace "GIFT:(\d+)" with "Thank you for your gift of \$$1."