Jump to content
Server Maintenance This Week. ×

Export Field Contents quirk


This topic is 6203 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I have a field that compiles the record data into iCal code (.ics). Then I use the ExportFieldContents function to create a .ics file to import into iCal. But! When it exports the data, it adds really weird formatting that makes iCal unable to read it. The .ics file starts with a random "<^" and then has weird spacing format issues (I have to press the arrow key or delete key two times in order to even move the cursor).

If I copy the field contents and manually create a .ics file, iCal sees it no problem and imports it. But if I use ExportFieldContents, iCal says the file is "corrupt." Any ideas on how to fix this problem?

Thanks!

Link to comment
Share on other sites

Okay, this zipped file contains two examples of my data export.

iCal_fieldExport.ics is the data directly exported from the global field.

iCal_CopyPaste.ics is the data copied from the global field and pasted into a TXT document then saved with the extension ".ics"

If you open them up with iCal, iCal_CopyPaste.ics works but iCal_fieldExport.ics does not --- it gives an "unreadable" error. If you open both of them up in a rich text editor (such as BBEdit, not word or TextEdit), you can see the "<^" thing and the spacing issue I'm talking about with iCal_fieldExport.ics.

Ideas?

ics_Files.zip

Link to comment
Share on other sites

It's the utf-16 encoding. Which you can see if you look at the lower left, in the status bar of BBEdit (which is a text editor, TextEdit is a rich text editor). That's the default (and only) encoding for Export Field Contents.* The "good" file is utf-8.

A quick way, on a Mac, of getting a utf-8 file is to just write the file using a shell script command, running it with AppleScript, in a Perform AppleScript step. It produces a utf-8 file by default, and also translates FileMaker field internal carriage returns (ASCII 11).

-- tell application "FileMaker Pro Advanced"

	copy cell "filename" of current record to fileName

	copy cell "Text_" of current record to exportMe

	do shell script "echo -n " & quoted form of exportMe & " > ~/Desktop/" & quoted form of fileName

	-- -n prevents a final line feed from being added

-- end tell

~/Library/Calendars/ is the user's calendars directory, if you'd rather use that.

You don't need the tell FileMaker lines inside FileMaker; but you do need them in Script Editor, so I leave them in, but --commented. In the above I'm only taking the file name from a FileMaker field, adding it to the path to the user's desktop.

Link to comment
Share on other sites

Oh man Fenton, that's perfect! I thought about AppleScript briefly but am not very fluent. I made some mods to your AppleScript so people can specify a custom filename (via Filemaker CustomDialog).

(Ooo, understood about BBEdit and TextEdit. Makes sense.)

Perfect! Thank you so much! Lifesaver!

Link to comment
Share on other sites

This topic is 6203 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.