Remote containers are a great new feature in FileMaker. It lets you keep the size of your databases smaller. I have one database that went from over 6GB to just 500MB when I moved the containers from internal to remote. It made the backups faster and saved a lot of space on their backups! In this first installment of a short series about containers, we will review how to reference a remote container.
When I changed the container definitions to be remote, I discovered a small change that needed to be addressed. When referencing the container field I noticed the file name is now different. I stumbled upon this while creating a script to send an email with the contents of the container field attached.
Let me explain…
If you want to export the contents of a container field to a location, you might want to do this to attach the file to an email. Typically I will use this variable to export the file in the field ‘File’;
SetVariable[$Path; Get(TemporaryPath) & Customers::ContainerLocal
If you put this in the data viewer you might see something like this;
However when the file is in an remote location, calling the field name no longer just returns the name of the file in the container field. It is a two line text describing the location also
If the file was not stored remotely the variable might look like this;
There are two things to notice between a Local and a Remote Container. The first thing to notice is on a remote container the word ‘remote’ is inserted. The second thing is that there is a second line reported that is the location of the remote file. To simplify it lets just look at the field part. Put either Customers::ContainerLocal or Customers::ContainerRemote into the data viewer;
Note, as mentioned above, the remote container field returns two lines. The first line is the name of the file inserted into the container field (prepended with ‘remote:’), the second line is the relative path to the file in the operating system.
To account for this new information you need to update how this information is used. First just get the first line, second remove the word ‘remote’ from the first line. To do this use both the GetValue command to get just the first line. Then use the Substitute command to remote the ‘remote:’ prefix. (don’t forget the colon). This can be done in one line like this;
The script step at the begging of the essay would be more like this;
Get(TemporaryPath) & Substitute( GetValue( Containers::ContainerRemote; 1); “remote:”;””)
We will be seeing more and more instances of remote containers and this is just one technique to make them more useful. The best part is that this works for NON remote containers too! Even if you aren’t yet using remote containers, it’s a good idea toimplement this technique now in order to future proof your solution.
Coming up in the next installment will be how to manage remote containers in a live hosted system; Things to Know Before You Deploy.