Let’s continue to look at the updates with the Execute FileMake Data API script step in Claris FileMaker 21. In this blog, we will look at how to use update. Be sure to read Execute FileMaker Data API – Part 1 – Create, since I am expanding the demo file with each post. Let’s jump in!

So, in the last post we learned how to create a record as seen here:

Now, when we click the Contact Name in the portal row, it opens in the same card as before. However, because we have a FileMaker record id, it will set the fields in the window.

Here is the script setup. Very simply, I am passing the record id as part of the json. If it has the record Id, then it sets the fields. Otherwise, it would just be empty, since it’s a new record.

This shows the json in the script parameter on the Add button:

Next, here is the json in the script parameter for the Contact Name.This is referencing all the fields in the table, including the record id.

Finally, we’ll make a change to the email address as see here:

The controller script still exists for both the Save Basic and Save Reusable.  The difference is we have an additional condition in the script for the record id, which will call the update script instead.

We’re going to start with the basic script Contact – Update Record – Execute FM Data API. The flow of the script stayed the same as the Contact – Create New Record – Execute FM Data API script, but we have a couple of small changes.

First, the action key changed from create to update. Second, the recordId key was added.

If we look at the Utility | Update Record – Execute FM Data API { json } script, it takes on the same changes. However, we set the action to update on line 18 in the script. The recordId is set in the json, as seen in the sample json at the top, and is passed as a parameter in the script Contact – Create / Edit – Save – Controller { type }.

Finally, as before, clicking either Save button will update the record as you can see in the portal.

Keep an eye out for the last post in this series and learn how to use the Execute FileMaker Data API to delete and duplicate records. Enter your info below to get the download and enjoy your week!