8 Replies Latest reply on Jul 11, 2014 12:00 AM by hjgunn@mmedia.is

    Adding a merge field to a text field...


      I'm adept at using merge fields in layouts so that's not a problem.


      However I want to create form letters that are then selected placed in a text field and sent to a group of students etc.


      Placing merge fields in a text field seems impossible.

      Word can't connect to FM unless the Fileformat is FM 7

      Neither can Excel


      Or is there a version of office for mac and or windows that can connect to FM 13 server?




      So it somehow seems the only method left is to write a script for each letter and using the setfield command to completely create the contents of the letter.

      I really wonder if there isn't some simpler way to acchieve this?


      Any ideas?




        • 1. Re: Adding a merge field to a text field...

          Hans -


          I'm not 100% sure what you're asking, but are you wanting to do something like this:


               "Hello, <<firstName>>. I'm Hans, and welcome to our community ..."


          If that's the case, you can use a calculation to insert the contents of the field using Substitute and some field delimiters in your text field. Something like this:


               Substitute ( textField ;

                    [ "{{firstName}}" ; "<<" & tableName::firstName & ">>" ] ;

                    [ "{{lastName}}" ; "<<" & tableName::lastName & ">>" ]



          Then, wherever you want to insert a merge field into your text, just use the delimiters and the name of the field. The calculation field then becomes the source for your merge.


          You can get fancier, if you like, by using text parsing function to grab the start and end points of the delimiters, extract the field name, and then use Evaluate to process out the values. This is slightly more complex to program, but more flexible (contingent on the fields actually being present, of course).





          • 2. Re: Adding a merge field to a text field...

            Thank you Mike


            So you are saying in the template I write something like


            The temperature today is <<Temp>> with a <<Rain>> percent probability of rain.


            I then write a script that parses the text for all my custom merge variables and replaces them with the actual values.

            Am I understanding this correctly?



            • 3. Re: Adding a merge field to a text field...

              No, you create a calculation field that does the substitution and use that.

              • 4. Re: Adding a merge field to a text field...

                Ok, thank you.

                I'll study this a bit.



                • 5. Re: Adding a merge field to a text field...
                  Stephen Huston

                  I've used calculation/substitution functions to generate form letters for years by providing users with a key for what to enter such as:

                  • enter "xxxFirst" to place the First Name in the text
                  • enter "xxxBD" to place the Birthdate in the text.

                  Then I give them a global text field into which they type and format their letter, but use a non-global calc field (text result) for the actual letter output field, using this type of nested text substitution calc:


                  • Substitute ( Substitute ( gLetterInputField ; "xxsFirst" ; FirstNameField ); "xxxBD" ; BirthdateField )


                  Then, wherever the user types xxxFirst, the actual contents of the FirstNameField will appear within the text, etc.

                  • 6. Re: Adding a merge field to a text field...

                    Since my last reply the lights have been turned on and I got what Mike was talking about.  ;-)


                    However I need to take this a bit further as I need to keep a copy of each letter in the database to be able to look them up later without having to open a folder as so many people still do.


                    I was thinking to have two tables, templates and letters.

                    And to offer a popuplist containing the merge codes just as Stephen was mentioning


                    In the temp table I create one record for each form letter template we need to store.

                    Then each time I need to send one of the stored letters the user finds the group of receivers

                    Then a list of available form letters is displayed

                    The user selects one

                    The script copys the contents of the template into a variable

                    It then replaces the pseudo codes with the actual fields content

                    It stores the result in a field in the letter table

                    It prints the resulting letter into a PDF

                    It imports the PDF into the letter record and pronto we have a hard copy of the intended letter


                    I could then also have a layout for adhoc letters that are not stored in the template file.


                    I could also throw in a batch table to be able to see which transmissions have taken place.


                    This does of course need some refinement as the above is little more than a frame but in general it should work.  -  I think.

                    • 7. Re: Adding a merge field to a text field...

                      I did pretty much what you are trying to accomplish with the help of the VTC training series.  It covers much of what you want to do.  I have a popup list of merge fields, list of available form letters, etc.

                      I use this for customer letters.  I create a template letter, decide if I want it to print on Company Letterhead or not.  I also added a picker list of customers, which I can sort/find in many combinations-so I can just check a bunch of customers, and build a letter for each.  Then I can go thru each letter, and customize it further. After I print all the letters (all scripted) I can add to the customer contact table, the date, and letter sent to the customer. I didnt save as PDF, then import PDF.

                      • 8. Re: Adding a merge field to a text field...

                        Thank you Steve


                        BTW,what is the VTC training series?


                        Never mind, I got it: www.vtc.com   :-)