Long URLs in FileMaker

If you have a long URL in FileMaker, it is no problem. You could just have a button to open the URL from a text field. However, if you export the same URL to a PDF to circulate the information to others who don’t use FileMaker, you can hit problems.
The same URL in a PDF

Above is the same URL in a PDF, exported from FileMaker. It looks like it should work fine. If you click on it, however, you will have a broken URL. The problem is that the URL spans two lines of text and the PDF readers often become confused by this.
Clicking on the URL results in a ‘Page Not Found’ Error.

Adobe Acrobat Reader, or Preview on the Mac, will clip the URL to the first line, effectively breaking the link and making things complicated for the person trying to view the information from the PDF. Of course a savy user would know to copy the entire link and paste it into their browser, but that move is beyond the capabilities of some users and you want to make things easy.
Updated ‘Shorten URL’ FileMaker demo database

Regular readers of this blog will recall I wrote on the topic of URL Shortening in FileMaker recently, and created a demo database that does just that. I have updated this database to include a new script, designed to copy and paste into any solution.
Copy the script called ‘Shorten URL using Bit.ly’ into your database.

Launch the database and go into ‘Manage Scripts’. Click on the second script and copy it. Go to your own database and paste it in the same area of your own solution.
Add a new field to your database called ‘Shortened URL’

Make it a text field.
Copy the hidden Web Viewer from the demo database into your own database.

This Web Viewer is already named ‘URLShorteningWebViewer’ to match the named web viewer object in the script you copied in the first step. It is also set up to be semi invisible to minimize screen clutter. Add this to whatever layout you are going to do your processing on in your own database.
Edit the Script – just two fields to update

There are just two fields to change in the script. The field you are pulling the original long URL from and the field you want to put the shortened URL into. Edit the script step for the first field to match your starting URL field. Then use the newly created ‘Shortened URL’ field for the second field.
Set a Script Trigger onto your URL field

To make the script dynamic, and assuming you are using FileMaker 11, create a script trigger on the starting URL field. If you don’t have FileMaker 11, use a button to cause the script to run.
Set the Script Trigger to run OnObjectExit

Click on ‘OnObjectExit’ and select the script ‘Shorten URL using Bit.ly’ in your solution. Then click OK.
Tabbing from the field causes the script to run

Now, when you add a URL, as soon as you leave the field, it will get a shortened URL. You could also create a batch script to run through a group of URLs to add shortened URLs to a group of records.
Download the demo database here.
Related Articles:
Shrinking Batches of PDF Files on a Mac for FileMaker Server 12
Shortening URLs using FileMaker
Blast from the Past: FileMaker Pro 6 Review
Thank you for your tips and tricks.
They are very useful.
I never thought about the problem with longs URLs on printed PDFs.
I was looking for a way to do exactly this, and came across both of your excellent tutorials. I added the bit.ly script exactly as you suggest but when I run it it doesn’t work from either the script incorporated in my database or from the script included in your demo file.
It seems that the specified destination for the URLShorteningWebviewer has changed. Ijust get a 410 gone error message when I try, and what comes back is the source for that page. I have no idea where it SHOULD go to, or what to modify in the script to send it to the right place. Any clues?
I have now figured this out. Seems that the submission to bit.ly must now be in this format:
http://api.bitly.com/v3/shorten?login=bitlyapidemo&apiKey=INSERT YOUR API KEY HERE;longUrl=http%3A%2F%2Fbetaworks.com%2F&format=txt
Got it to do that, and it worked.
Thanks for the update Robert. It looks like Bit.ly has added the requirement that you sign up for an API key and include that in the request. I took your API key out of the string in your comments.
This doesn´t work for me:
bit.ly returns INVALID_URI as long as one uses “http%3A%2F%2”. This works in the normal browser, but not in the webviewer.
This works for me:
– add a field “suffix” with the value &format=txt
– in the url field enter
http://api.bitly.com/v3/shorten?login=&apiKey=&longUrl=http://
(replace and with your data)
– alter the shorten Script var “$SearchString” to “$APIURL & $URL & $suffix”
WordPress destroys my message
the url is
h t t p : / / api.bitly.com/v3/shorten?login= &apiKey= &longUrl=http://