Try the Extend function.
Maybe I'm wrong but my understanding is that the Extend function works on a non-repeating field (or only the first repetition of a repeating field).
TEMPLATE is a repeating text field (each repetition containing different content) as it is meant to be a multi-page letter (each repetition a different page). I need the calculation to work on all repetitions of TEMPLATE.
1 of 1 people found this helpful
The following script will do what you want:
Set Variable [ $repetition; Value:4 ] //set this value to the highest number of repetitions if known, or any number larger than the highest possible//
Go to Field [ YourFieldName [$repetition] ]
Set Field [ YourFieldName [$repetition]; Substitute ( Get ( ActiveFieldContents ) ; "<<SUB>>" ; "I Did It!" ) ]
Set Variable [ $repetition; Value:$repetition - 1 ]
Exit Loop If [ $repetition = 0 ]
Go to Field [ ]
As per note on line one of the script, all you need to do to make sure it deals with all repetitions is to start the variable counting down at a number that is higher than the highest possible repetition number it wil encounter. The script will do nothing until it gets to a live repetition and little time will be taken by the initial dummy cycles.
["<<FamilyName>>"; "Jones"] )
This should work for all repetitions of the LETTER field. However if you want to reference a field instead of the literal text "Bill", you must wrap it in Extend() function, e.g.
Substitute ( Template ;
[ "<<FirstName>>" ; Extend ( FirstName ) ] ;
[ "<<FamilyName>>" ; Extend ( LastName ) ]
Thanks Michael. Your suggestion works exactly as I wanted it to. I'd have never thought to put the Extend function onto the field name that I was referencing. I kept putting it on Template and then gave up on the idea of using Extend
Thanks also to keywords, that was a handy little script that also worked well
Note that repeating fields are probably not the best choice here. Consider using records in a related table instead.
Thanks for your advice. Can you please give me a little bit more info?
Do you mean you'd use an individual record for each "page" of the Template (i.e. in a Template table) and pull the records contents in via a relationship into the Letter table/fields?
Can you please give me a little bit more info?
At this point, not really. Why don't you explain what you are doing in more detail.
I'm just playing around seeing how a multi-page merge letter functionality might work. I won't take more of your time. Thanks, your tip with extend was a great help
Michael's suggestion is worth paying attention to. I try to stay away from repeating fields, and use tables, if it makes sense. You can create a template table with the fields you need.
Of course, it would really help if people started with what they are trying to achieve as opposed to a calculation not functioning, but hey, we can only dream here.
agnes b. riley . filemaker and web development
T 201-299-6223 (NJ) . 212-842-8830 (NY) . 917-660-7221 (C)
FileMaker Certified in 10 and 11
I thought I stated pretty clearly what I was trying to achieve, namely "Simple merge using one substute calculation on numerous field repetitions". Michael and keywords solved my problem quickly and cleverly (thanks again guys).
I'll take your advice and next time include a lot more context as a step towards making your dreams come true
I thought I stated pretty clearly what I was trying to achieve
Well, not really: I'm still not sure what each repetition represents. You have every right to share only as much as you want to - but it is in your best interest to expand the picture, not anyone else's. A lot of times folks are asking how to drive a car, when they should really be taking the train.
Thanks. I'll take your and Agnes' advice and include a lot more context next time. I appreciate everyone's time and help