Script for reinserting files in container field

Discussion created by arby on Jan 25, 2017
Latest reply on Jan 27, 2017 by arby

I have a few hundred photos in container fields that I inserted with the option Store only a reference to the file turned ON. The storage option for the container field is Store container data externally.


I need to reinsert those photos with the option Store only a reference to the file turned OFF. The reason is that I’m preparing the database for a WebDirect implementation, and WebDirect does not support container files as references. The storage option—external--will remain the same. Obviously, I’d like to do this via a script rather than manually.


The document in_depth_container_fields_fm14_en.pdf (page 15) contained exactly what I thought I needed:

"Files inserted by reference can be reinserted as external data using the following 2-step FileMaker script:"
Set Variable [ $path; GetAsText (referencedContainer) ]
Insert File [ Insert; referencedContainerField ; $path ]


This script contains two errors: 1) step 1 should say GetAsText (referencedContainerfield) so it matches the field reference in step 2 and 2) $path in step 2 should be enclosed in quotation marks (yes, even though it's a variable. When you enter the variable in the Specify file dialog box, FileMaker encloses the variable in quotes in the Insert File script step).


I ran this script (with the necessary changes to the field name to match my database), but it didn’t work.There was no change to the GetAsText(containerField) result


The test of success, I believe, is this: When an image is inserted with the option Store only a reference to the file turned ON, the result of GetAsText(containerField) look like this:




imagewin:/C:/Users/MyDocuments/Databases/My Database/Graphics/graphic.jpg


When a file has been inserted with the Store only a reference to the file turned OFF, the result of GetAsText(containerField) should look like this: