I'm not sure about the preview but you don't need the export / import procedure.
You can use this:
# get the filename from container
Set Variable [ $filename ; GetContainerAttribute ( theContainer ; "filename" ) ]
Set Field [ theContainer ; Base64Decode ( Base64Encode ( theContainer ) ; $filename ) ]
This will reinsert the container contents ( in memory ) and according to filename extension FileMaker will try and guess what type of document it is and create a preview if possible. I think it's kinda like dragging and dropping the file onto the field.
So if you can't guess, let it rip through all!
And even better, you can get rid of the Set Variable step and put the GetContainerAttribute () within the Set Field.
It will of course evaluate before the field is set.
It can be made into a single step or a even a custom function for auto enter calculation.
cf_Interactive ( Self )
If you want it behave this way by default that is.
Thanks, election. That sounds quite reasonable and had not thought of it that way (decoding/encoding). I'll give it a while and your assistance is much appreciated.
Unfortunately, this technique doesn't work.
I use this technique on solutions with Windows servers because Windows does not give a preview. So you have to run this decode/encode on a Mac. In fact what I usually do is have file inserted as a file and not PDF and then test if the SystemPlatform is 1, I then doe this decode/encode for whenever someone is importing a PDF. What I haven't figured out is what I can do to test which ones don't have previews and which ones do.