iOS Shortcuts to the FileMaker Data API

Shortcuts, on iOS, are a new way to automate tasks by mixing together apps, content on your iOS device and web APIs into custom workflows. Now, via the FileMaker Data API, you can use shortcuts as a way to interact with your FileMaker solutions.

Here’s an example of automatically uploading a photo from your iPhone into a FileMaker container field, via iOS shortcuts to the FileMaker Data API.

Here’s the example file and shortcut for you to download: Shortcuts and FileMaker

Important note: At the moment, this whole technique works with FileMaker 17 Server on Windows. It’s not working with FileMaker Cloud nor with FileMaker 17 Server on macOS. Stay tuned for updates, once we identify a reliable solution for these issues!

What’s a shortcut?

A shortcut is a set of tasks, built in multiple steps, managed through the Shortcuts app on iOS. The building block of a shortcut is called an “action”. Each action is a single step in a task, and each shortcut consists of one or more actions.

Documentation for the Shortcuts app (What’s a shortcut?) gives an example of building a “Surf Time” shortcut: grabbing the surf report, giving an ETA to the beach and then launching your surf music playlist.

Shortcuts? "Hey, I’m a FileMaker developer!"

No problem! Think of a shortcut as similar to a FileMaker script. And an action would be like a single script step. So, how can we use this fantastic app with FileMaker?

Easy! Using the FileMaker Data API, you can integrate a shortcut with the FileMaker Platform to do things like create, edit and delete records.

And not only that: you can also build a shortcut to upload a file or an image to a container field. Or imagine using Siri to ask questions and get all kind of answers from your FileMaker solutions…yes, shortcuts controlled with your voice!

And please note, FileMaker Go is not required, at all. Users on iPhone and iPad can use shortcuts from their iOS apps and content directly to FileMaker, through the Data API. Let me show you how this is done…

Let’s start with the basics

In this simple example, I will create a shortcut that, after connecting via the Data API to my FileMaker server, will take an image from the Photos application on my iPhone and upload it into a container field.

First of all, download and install the Shortcuts app from the App Store (it is free) from the following link:
https://itunes.apple.com/us/app/shortcuts/id915249334

FileMaker shortcuts splash

Once installed and opened, just click on “Create Shortcut” to create a new document.
Select the actions you want to use from the guided search and add them to the document.
Each action is performed progressively from the beginning to the end of the document.

In our case the steps will be the following:

Step 1

Set a variable from a text block with the URL value of our server where the FileMaker Data API is active.

Note: Remember to use an SSL certificate on your FileMaker Server!

Text + Add to variable

FileMaker shortcuts step 1

Step 2

Ask the user to enter the credentials and save them in a variable.

Ask for Input + Add to variable
(this to avoid storing the credentials in our action)

Repeat the steps also for the password request.

FileMaker shortcuts step 2

Step 3

Concatenate username and password separating them with a “:” and then perform an encode in base64, to manage the Basic Authentication provided by the Data API.

Text + Base64 Encode

FileMaker shortcuts step 3

Step 4

Set the URL to log in via Data API (URL/fileName/sessions).
Make an HTTP POST call to receive the token and authenticate the user.

URL + Get Contents of URL

Set as Method: POST and as Headers:
Content-Type: application/json
Authorization: Basic Base64 Econde (this value comes from our previous variable set above)

FileMaker shortcuts step 4

Step 5

Get the response from the endpoint, parse the received object and save the token to a variable.

Get Dictionary Value (response) + Get Dictionary Value (token) + Add to Variable

FileMaker shortcuts step 5

Note: I’m using the If statement to check if the token variable exists.

Step 6

Set the URL to make the record creation request via Data API (URL/fileName/layouts/layoutName/records)
Make a http POST call to receive the ID of the new record created.

URL + Get Contents of URL

Set as Method: POST and as Headers:
Content-Type: application/json
Authorization: Bearer token

FileMaker shortcuts step 6

In the request body add a new field and name it: fieldData and as value compile the JSON object (dictionary) with the information of the fields that you want to enhance when creating the record. In our case we are passing the following item: data = “Test from shortcuts”.

Step 7

Get the response from the endpoint, parse the received object and save the value of the ID record created in a variable.

Get Dictionary Value (response) + Get Dictionary Value (recordId) + Add to Variable

FileMaker shortcuts step 7

Step 8

Open the camera roll (Photos, on iOS) to select the image to be loaded into the container field.

Select Photos

FileMaker shortcuts step 8

Step 9

Set the URL to request the upload container via Data API (URL/fileName/layouts/layoutName/records/id/containers/containerNameField/repetition)
Make a http POST call to receive the ID of the new record created.

URL + Get Contents of URL

Set as Method: POST and as Headers:
Content-Type: multipart/form-data
Authorization: Bearer token

Request body (type Form):
Add a new field and name it: upload and select the photo variable using the “Magic Variable“*

FileMaker shortcuts step 9

Step 10

Set the URL to log out via Data API (URL/fileName/sessions/token)
Make an http DELETE call to delete the session on the FileMaker server for the logged in user.

URL + Get Contents of URL

Set as Method: DELETE and as Headers:
Content-Type: application/json

FileMaker shortcuts step 10

*Magic Variable

In the steps of our actions, you can enter manual values or recall them from the variables created…Or, in some cases, you can use the “Magic Variable” selector to get help from the application in using a variable in the next step.

magic variables

Conclusion

Shortcuts, on iOS, are very interesting and may open up a lot of new opportunities for FileMaker interactions with third party applications, content and web APIs. I built an example of automatically uploading a photo from your iPhone into a FileMaker container field, via iOS shortcuts to the FileMaker Data API. Hopefully, you’ll test it out, and also try building shortcuts that work with other iOS apps, or perform tasks that interact with other functionality in FileMaker.

And, please stay tuned! In a followup blog post, we’ll be asking different questions to Siri to show how it can interact with FileMaker to provide you with answers.

Download the example file and shortcut: Shortcuts and FileMaker

3 thoughts on “iOS Shortcuts to the FileMaker Data API

  1. Not sure how to use the example files. Please explain. Also a little confused on how to put the “Add to Variable” action into the Shortcuts library. Thanks for the article.

    1. Hi torch_55,

      upload the file DAPI on your FileMaker Server 17 with Data API enabled and SSL certificate installed
      Follow the steps from 1 to 10.
      Every action is chosen from the internal library  in the Shortcuts app (“Add a variable” is an action you can pick from that library, you can use the search area to find this action)

      Note: on step 6, you should specify Dictionary as a value of the field fieldData.

      If you need more help contact us.

Leave a Reply