Professional Software Development for FileMaker®

FileMaker Business Alliance
FileMaker 8 Certified Developer
FileMaker 10 Certified Developer
SUI Solutions is an independent entity and this web site has not been authorized, sponsored, or otherwise approved by FileMaker, Inc.

New to FileMaker?

FileMaker 11

Learn about the most
incredible database now!

FieldNames2FieldValues

Filemaker custom function that replaces field names with field values in Text.

Format

FieldNames2FieldValues ( Text )

Parameter

Text - template text with field names

Data type returned

text

Description

Replaces all occurrences like {{<Table Name>::<Field Name>}} to actual field values.

Example

Input:

FieldNames2FieldValues ( "Dear {{Customers::Customer_Name}} , thank you for buying our {{Products::Product_Name}}, a powerful FileMaker template to help plan your events, meetings and tasks! Best Regards, SUI Solutions team." )

Output (field names replaced to field values):

Dear John Smith, thank you for buying our SUI Calendar, a powerful FileMaker template to help plan your events, meetings and tasks! Best Regards, SUI Solutions team.

Source code

Select all
Let ([ openMacrosPosition = Position ( Text; "{{" ; 1 ; 1 ); closeMacrosPosition = If (Position ( Text; "}}" ; 1 ; 1 )=0; -2; Position ( Text; "}}" ; 1 ; 1 )); macrosContents = Middle ( Text; openMacrosPosition + 2 ; closeMacrosPosition - openMacrosPosition - 2); replacementText = GetField ( macrosContents ); res = Replace ( Text ; openMacrosPosition ; closeMacrosPosition - openMacrosPosition + 2 ;  replacementText ); macroscount = PatternCount ( res ; "{{" ) ]; If ( macroscount=0 ; res; FieldNames2FieldValues (res) ) )