{"id":6,"date":"2008-08-02T03:50:39","date_gmt":"2008-08-02T02:50:39","guid":{"rendered":"http:\/\/simoncpage.co.uk\/blog\/?p=6"},"modified":"2009-01-04T04:41:59","modified_gmt":"2009-01-04T03:41:59","slug":"filemaker-to-vcard","status":"publish","type":"post","link":"https:\/\/simoncpage.co.uk\/blog\/2008\/08\/filemaker-to-vcard\/","title":{"rendered":"Filemaker | create vCard .vcf and carriage returns in text export"},"content":{"rendered":"<h2>AIM:<\/h2>\n<p>To find a solution to create a vCard file from a Filemaker contact database &#8211; ideally natively with no plug-in. (<strong>vCard<\/strong> [.vcf] is a file format standard for electronic business cards. vCards are often attached to e-mail messages. They can contain name and address information, phone numbers, URLs, logos, photographs, and even audio clips.)<\/p>\n<h2>SOLUTION:<\/h2>\n<p>The first step was to map out the structure of a vCard to be able to replicate it into a filemaker field.<\/p>\n<p>The following is an example of a vCard file containing information for one person:<\/p>\n<blockquote><p>BEGIN:VCARD<br \/>\nVERSION:2.1<br \/>\nN:Gump;Forrest<br \/>\nFN:Forrest Gump<br \/>\nORG:Gump Shrimp Co.<br \/>\nTITLE:Shrimp Man<br \/>\nTEL;WORK;VOICE:(111) 555-1212<br \/>\nTEL;HOME;VOICE:(404) 555-1212<br \/>\nADR;WORK:;;100 Waters Edge;Baytown;LA;30314;United States of America<br \/>\nLABEL;WORK;ENCODING=QUOTED-PRINTABLE:100 Waters Edge=0D=0ABaytown, LA 30314=0D=0AUnited States of America<br \/>\nADR;HOME:;;42 Plantation St.;Baytown;LA;30314;United States of America<br \/>\nLABEL;HOME;ENCODING=QUOTED-PRINTABLE:42 Plantation St.=0D=0ABaytown, LA 30314=0D=0AUnited States of America<br \/>\nEMAIL;PREF;INTERNET:forrestgump@walladalla.com<br \/>\nREV:20080424T195243Z<br \/>\nEND:VCARD<\/p><\/blockquote>\n<p>vCard defines the following property types: FN, N, NICKNAME, PHOTO, BDAY, ADR, LABEL, TEL, EMAIL, MAILER, TZ, GEO, TITLE, ROLE, LOGO, AGENT, ORG, CATEGORIES, NOTE, PRODID, REV, SORT-STRING, SOUND, URL, UID, VERSION, CLASS, KEY [1]. In addition, because vCard augments RFC-2425, a standard for directory information, the following property types are also supported: SOURCE, NAME, PROFILE, BEGIN, END.<\/p>\n<p>This is fairly straight forward to map from a contact database in Filemaker via a calculation field but here is a custom function that wraps it all up nicely:<\/p>\n<blockquote><p>\/* Returns text formatted as a vCard<\/p>\n<p>This function takes contact info and formats it into the vCard format as text.\u00a0 The result field contents can be exported and opened as a .vcf file which can be opened in the Apple Address Book and other software that supports the vCard format.<\/p>\n<p>Written by Chris Pye &#8211; <a href=\"mailto:info@mactec.com.au\">info@mactec.com.au<\/a><\/p>\n<p>vcard ( FirstName; LastName; Org; Title; Phone; Fax; Mobile; Email; Street; Suburb; State; Zip; Country )<\/p>\n<p>*\/<\/p>\n<p>\/\/ DECLARE VARIABLES<\/p>\n<p>Let ( [<\/p>\n<p>\/\/ All relevant fields are mapped here<\/p>\n<p>_LastName = LastName;<br \/>\n_FirstName = FirstName;<br \/>\n_MiddleName =&#8221;&#8221;;<br \/>\n_Title = Title;<br \/>\n_Suffix = &#8220;&#8221;;<\/p>\n<p>_Org = Org;<br \/>\n_Dept = &#8220;&#8221;;<br \/>\n_JobTitle = &#8220;&#8221;;<\/p>\n<p>_Phone1Value = Phone;<br \/>\n_Phone1Label = &#8220;work&#8221;;<\/p>\n<p>_Phone2Value = Fax;<br \/>\n_Phone2Label = &#8220;fax&#8221;;<\/p>\n<p>_Phone3Value = Mobile;<br \/>\n_Phone3Label = &#8220;cell&#8221;;<br \/>\n_Email1Value = Email;<br \/>\n_Email1Label = &#8220;work&#8221;;<br \/>\n_Address1Street = Street;<br \/>\n_Address1City = Suburb;<br \/>\n_Address1State = State;<br \/>\n_Address1Code = Zip;<br \/>\n_Address1Country = Country;<br \/>\n_Address1Label =&#8221;work&#8221;;<\/p>\n<p>_FullName = FirstName &amp; &#8221; &#8221; &amp; LastName;<\/p>\n<p>\/\/ I have had problems with bad characters in the street line, so added this<br \/>\n_FilterText = &#8220;abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.-()\/\u00b6\\\u2019 []?,!#&#8221; &amp; &#8220;&#8216;&#8221;;<\/p>\n<p>\/\/<br \/>\n\/\/ NOW START FORMATTING THEM FOR THE VCARD FORMAT<br \/>\n\/\/<\/p>\n<p>vname = _LastName &amp; &#8220;;&#8221; &amp; _FirstName &amp; &#8220;;&#8221; &amp; _MiddleName &amp; &#8220;;&#8221; &amp; _Title &amp; &#8220;;&#8221; &amp; _Suffix;<\/p>\n<p>vfname = _FullName;<\/p>\n<p>vtel1 = If( not IsEmpty ( _Phone1Value );&#8221;TEL;&#8221; &amp; If(PatternCount (_Phone1Label ;&#8221; &#8221; )=1;Substitute ( _Phone1Label ; &#8221; &#8221; ; &#8220;;&#8221; );_Phone1Label) &amp; &#8220;:&#8221; &amp; _Phone1Value &amp; &#8220;\u00b6&#8221;;&#8221;&#8221; );<\/p>\n<p>vtel2 = If( not IsEmpty ( _Phone2Value );&#8221;TEL;&#8221; &amp; If(PatternCount (_Phone2Label ;&#8221; &#8221; )=1;Substitute ( _Phone2Label ; &#8221; &#8221; ; &#8220;;&#8221; );_Phone2Label) &amp; &#8220;:&#8221; &amp; _Phone2Value &amp; &#8220;\u00b6&#8221;;&#8221;&#8221; );<\/p>\n<p>vtel3 = If( not IsEmpty ( _Phone3Value );&#8221;TEL;&#8221; &amp; If(PatternCount (_Phone3Label ;&#8221; &#8221; )=1;Substitute ( _Phone3Label ; &#8221; &#8221; ; &#8220;;&#8221; );_Phone3Label) &amp; &#8220;:&#8221; &amp; _Phone3Value &amp; &#8220;\u00b6&#8221;;&#8221;&#8221; );<br \/>\nvmail1 = If( not IsEmpty ( _Email1Value);&#8221;EMAIL;INTERNET;&#8221; &amp; LeftWords ( _Email1Label;1 ) &amp; &#8220;:&#8221; &amp; _Email1Value &amp; &#8220;\u00b6&#8221;;&#8221;&#8221; );<br \/>\nvad1 = If( not IsEmpty (_Address1Street); &#8220;ADR;&#8221; &amp; _Address1Label &amp; &#8220;:;;&#8221; &amp; Filter(Substitute ( _Address1Street;&#8221;\u00b6&#8221;;&#8221;\\n&#8221;) ; _FilterText) &amp; &#8220;;&#8221; &amp; _Address1City &amp; &#8220;;&#8221; &amp; _Address1State &amp; &#8220;;&#8221; &amp; _Address1Code &amp; &#8220;;&#8221; &amp; _Address1Country &amp; &#8220;\u00b6&#8221;;&#8221;&#8221;);<br \/>\nvorg = If( not IsEmpty (_Org);&#8221;ORG:&#8221; &amp; _Org &amp; &#8220;;&#8221; &amp; _Dept &amp; &#8220;\u00b6&#8221;;&#8221;&#8221;);<\/p>\n<p>vtitle = If( not IsEmpty ( _JobTitle ); &#8220;TITLE:&#8221; &amp; _JobTitle &amp; &#8220;\u00b6&#8221;;&#8221;&#8221;)<br \/>\n\/\/ AND THE FINAL FORMATTING<\/p>\n<p>];<br \/>\n&#8220;BEGIN:VCARD\u00b6VERSION:2.1\u00b6&#8221; &amp;<br \/>\n&#8220;N:&#8221; &amp; vname &amp; &#8220;\u00b6&#8221; &amp;<br \/>\n&#8220;FN:&#8221; &amp; vfname &amp; &#8220;\u00b6&#8221; &amp;<br \/>\nvorg &amp;<br \/>\nvtel1 &amp; vtel2 &amp; vtel3 &amp;<br \/>\nvmail1 &amp;<br \/>\nvad1 &amp;<br \/>\nvtitle &amp;<br \/>\n&#8220;END:VCARD&#8221;<\/p>\n<p>)<\/p><\/blockquote>\n<p>However even if you use\u00a0export field contents of a field using this custom function (or any for that matter) you get the paragraph returns wiped out (Windows and Filemaker 9.0v3 &#8211; I think on a Mac this is probably not the case &#8211; Windows needs CRLF or Carriage Return followed by a Line Feed and Mac only need the CR).<\/p>\n<p>I first had a search through some forums for a solution as obviously without this I could not export the field to a vcf file format as the paragraph returns are very important in the make up of this file.<\/p>\n<p>To export the file to another format I personally have\u00a0used the <a rel=\"nofollow\" href=\"http:\/\/www.troi.com\" target=\"_blank\">Troi<\/a> file plugin\u00a0and using the CreateFile and\u00a0 SetContents functions which basically creates a file (.vcf in this case) and then you set the contents of that new file to the field which is\u00a0displaying the output of the custom function (of\u00a0the contact you are on in the database). There is also an option to convert CR to CRLF on output for Windows users.<\/p>\n<p>However the aim of this was to do it <strong>without<\/strong> a plugin.<\/p>\n<p>Therefore to tackle this I have used and Export Records native function\u00a0using FMPXMRESULTS on a XSL style sheet\u00a0file &#8211; the example is below and works a treat:<\/p>\n<p><a href=\"https:\/\/simoncpage.co.uk\/blog\/wp-content\/uploads\/2008\/08\/filemaker_export_contents_vcf_text.zip\">filemaker_export_contents_vcf_text<\/a><\/p>\n<p>This solution can be used to create more than just vcf format files and hope this comes in handy for anyone else looking at this and finding problems on Windows.<\/p>\n<p>\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>AIM: To find a solution to create a vCard file from a Filemaker contact database &#8211; ideally natively with no plug-in. (vCard [.vcf] is a file format standard for electronic business cards. vCards are often attached to e-mail messages. They can contain name and address information, phone numbers, URLs, logos, photographs, and even audio clips.) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[4],"tags":[36,149,54,5,120,8,7,276,30,6],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/simoncpage.co.uk\/blog\/wp-json\/wp\/v2\/posts\/6"}],"collection":[{"href":"https:\/\/simoncpage.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/simoncpage.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/simoncpage.co.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/simoncpage.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=6"}],"version-history":[{"count":0,"href":"https:\/\/simoncpage.co.uk\/blog\/wp-json\/wp\/v2\/posts\/6\/revisions"}],"wp:attachment":[{"href":"https:\/\/simoncpage.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=6"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/simoncpage.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=6"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/simoncpage.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=6"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}