The trick is to use a $Path variable.
You can use export field contents with a $Path variable to export a copy of the container field to a known location such as the temporary folder. The script can then specify the same variable name in the attachment option in Send mail to send out the email.
Since you show a "store by reference" storage option, you can also use a calculation to extract the file path from the container field to put in your variable and that also produces a $Path variable that you can use with Send mail to attach the file.
See this thread for more on Container fields, $Path Variables and the script steps that can use $Path variables: Exploring the use of a $Path Variable in Scripts
I am in awe about the speed of your reply - thank you!
Will try to work through the post that you linked and hope that it is not too far over my head :-)
Wouldn't it be a reasonable project, to have such functionality built into the next FM update? I could imagine that this is a really useful feature.
One additional question: I guess if I have to do additional scripting to first get the path and the introduce the path, I won't be able to do it with a simple button function. Much rather I will have to write the script and then attach the script to the button ?
Thanks so much, Chris
Wouldn't it be a reasonable project, to have such functionality built into the next FM update?
I don't work for FileMaker but you can use their feature request form if you want to bring that idea to their attention: http://www.filemaker.com/company/contact/feature_request.html
I won't be able to do it with a simple button function. Much rather I will have to write the script and then attach the script to the button ?
Yes. But then I almost always use the perform script option for a button even when I could select a single script step. The reason is that I can copy and paste a button onto multiple layouts in my database. If I use the Perform Script option, I can edit the script to change the button's function and this one change applies to all the layouts where I placed that button. If I use a single step button option, I have to go to each layout and individually update that button.
Thanks again, PhilModJunk!
And even more so, since you don't work for "them" :-) !
Will work according to your suggestions and hope I'll understand.
I did try to work through the demo DB that you kindly provided via the DropBox link.
But I must say that while I am not a complete idiot with Filemaker, these variables are way over my head and this comprehensive demo appears confusing to me.
Would you be able to show me by a simple example how I could use this $path variable to link to a file that is referenced in a standard container field?
Maybe I can work it from there. After all, I do not seek complex features but only an automated email attachment process.
Thank you! Chris
Set Variable [ $FileName ; Value: //put calculation shown below here ]
Set Variable [$Path ; Get ( TemporaryPath ) & $FileName ]
Export Field Contents [ YourTable::YourContainerField ; “$Path” ]
Send Mail [
With the dialog for Send Mail open, click the attachments check box. In the dialog that opens, type: $Path in as the file reference to the file you want to attach.
The following calculation was copied from the cFileName calculation field in the demo file that you downloaded:
//This should work for all insertion and storage methods except Insert Object (Filemaker 11, WIndows only):
Let ( [ T = If ( LeftWords ( YourTable::ContainerField ; 1 ) = "remote" ;
GetValue( YourTable::ContainerField ; 1 ) ;
GetValue ( YourTable::ContainerField; ValueCount ( YourTable::ContainerField) )
) ; // If
L = Length ( T )];
If ( LeftWords ( T ; 1 ) = "remote" ; Right ( T ; L - 7 ) ; Right ( T ; L - Position ( T ; "/" ; L ; -1 ) ) )
) // Let
I am so thrilled: It works like a breeze.
Actually, I still can't believe that this really works - killer!
Would it in theory be possible to build something like this in logical if - else sequences?
Example: If "container field 1" is not empty, use that file - else check "container field 2" ....... and so on.
Your fan, Chris
Can I buy you beers????
Perfect again! Thank you very much indeed and I will stop asking here - even though it would be interesting to understand all the calculations with "length" and "position"....
If it was possible, I would suggest you for the "most valuable and most friendly forum support person"