67.5 F
Tampa
Tuesday, January 31, 2023
spot_img

Latest Posts

New Script Set: FileMaker Transactions


Claris released a new version of FileMaker, and it’s pretty exciting. Of course, the usual list of bug fixes and minor enhancements to the platform accompanied the update. Nonetheless, there’s at least one outstanding new feature: Transactions.  

In the database world, a transaction is any operation on an entity. In FileMaker world, it represents any change made to a record. Previously, we made most of our changes to our records, one record and one field at a time. And, when we clicked out of the field in FileMaker, it committed the record, thereby completing an operation for that entity – in other words, performing a transaction. This function helps keep all our data in sync with other users who concurrently access the database. But it can impede the performance of our system, especially in a wide area network (WAN) environment with poor network speed or high latency.  

Transaction Efficiency

A better model would be to group a batch of changes into a single transaction. For example, let’s say someone wants to reserve a series of books. Instead of creating a checkout record for each book one at a time, we could record a list of the call numbers for the books and the name of the person reserving them. Then, create a checkout record for all the books for that borrower in a script in one transaction. This approach provides one call back and forth to the server to save all that information at one time. In addition, it improves performance and data integrity in that if something goes wrong during the checkout process, we can revert the whole thing. It’s usually more complicated when we’ve already saved parts of the operation. 

Until now, developers could control transactions only from a single record context. This technique required staying on a single record and creating and modifying records from portals or global relationships. This methodology was practical but has limited us to making edits one record at a time. FileMaker’s new feature set allows developers to change multiple records with one transaction. This change should enhance the performance and scalability of any FileMaker solution significantly.  

Claris accomplished this by adding three new script commands to our toolbox:  

  • Open Transaction – opens the transaction and creates a transaction state. 
  • Revert Transaction – reverts all changes made during the transaction
  • Commit Transaction – closes the transaction and exits the transaction state. 

The idea is that we go into an open transaction state within a script. Then, we make a bunch of changes within the script. When we’re done making changes, we commit the transaction by sending the changes from our client to the server in one bundle. However, if we encounter an error or unintended condition while running the script, we can revert the entire transaction, which undoes all the changes we made.  

Transaction Notes

We’ve discovered a few nuances in our testing and discussion of this new feature.

Revert by Default

If we don’t expressly commit the transaction before the end of the script, it will revert by default. So, we will lose all of our changes unless we commit the transaction. 

Transaction States and Scripts

The transaction state we create during a script will only stay open while the script is running. We can’t exit a script when a transaction state is open. Every time a script ends, the transaction state will commit and exit. 

One of the first use cases we thought of using this new feature was to control user entry of a new record and allow them to exit and revert the new record if they decide to cancel the whole operation. However, this is only possible if we create a way of enabling them to do this while the script is running. If we want to allow users to make changes to a record in a batch, we’ll still have to use the old method to keep them from committing a record until they’re ready. So, this new transaction methodology is meant mainly for executing large-scale changes via a script.  

Transactions and Windows

Transactions are tied to the window that hosts them. Transactions that happen in other windows will be committed or reverted separately.  

Exiting the Transaction State

The rules for when we exit a transaction state and how different script steps affect the transaction state are both simple and complex. Generally, we commit the transaction state using the Commit Transaction command or exiting the script. That said, we need to review the rules for when a transaction state is automatically committed or reverted. There are a handful of exceptions that, as developers, we should know. For example, if we change windows by opening a new window, it will commit and end the transaction. 

Like many things, the devil is in the details with transactions in FileMaker. It is a whole new feature set for FileMaker. There are many things to consider, like managing multiple transaction states, running a subscript while in a transaction state, resolving validation errors when attempting to commit, etc. We suspect the developer community will be teasing out the various ways to use this new tool for months to come.

Stay tuned for our next blog post, exploring the opportunities above and outlining a potential use case and sample script for this new tool.

Keep me posted



Latest Posts

spot_imgspot_img

Don't Miss

[tdn_block_newsletter_subscribe title_text="Stay in touch" description="VG8gYmUgdXBkYXRlZCB3aXRoIGFsbCB0aGUgbGF0ZXN0IG5ld3MsIG9mZmVycyBhbmQgc3BlY2lhbCBhbm5vdW5jZW1lbnRzLg==" input_placeholder="Email address" tds_newsletter2-image="5" tds_newsletter2-image_bg_color="#c3ecff" tds_newsletter3-input_bar_display="row" tds_newsletter4-image="6" tds_newsletter4-image_bg_color="#fffbcf" tds_newsletter4-btn_bg_color="#f3b700" tds_newsletter4-check_accent="#f3b700" tds_newsletter5-tdicon="tdc-font-fa tdc-font-fa-envelope-o" tds_newsletter5-btn_bg_color="#000000" tds_newsletter5-btn_bg_color_hover="#4db2ec" tds_newsletter5-check_accent="#000000" tds_newsletter6-input_bar_display="row" tds_newsletter6-btn_bg_color="#da1414" tds_newsletter6-check_accent="#da1414" tds_newsletter7-image="7" tds_newsletter7-btn_bg_color="#1c69ad" tds_newsletter7-check_accent="#1c69ad" tds_newsletter7-f_title_font_size="20" tds_newsletter7-f_title_font_line_height="28px" tds_newsletter8-input_bar_display="row" tds_newsletter8-btn_bg_color="#00649e" tds_newsletter8-btn_bg_color_hover="#21709e" tds_newsletter8-check_accent="#00649e" embedded_form_code="JTNDIS0tJTIwQmVnaW4lMjBNYWlsQ2hpbXAlMjBTaWdudXAlMjBGb3JtJTIwLS0lM0UlMEElMEElM0Nmb3JtJTIwYWN0aW9uJTNEJTIyaHR0cHMlM0ElMkYlMkZ0YWdkaXYudXMxNi5saXN0LW1hbmFnZS5jb20lMkZzdWJzY3JpYmUlMkZwb3N0JTNGdSUzRDZlYmQzMWU5NGNjYzVhZGRkYmZhZGFhNTUlMjZhbXAlM0JpZCUzRGVkODQwMzZmNGMlMjIlMjBtZXRob2QlM0QlMjJwb3N0JTIyJTIwaWQlM0QlMjJtYy1lbWJlZGRlZC1zdWJzY3JpYmUtZm9ybSUyMiUyMG5hbWUlM0QlMjJtYy1lbWJlZGRlZC1zdWJzY3JpYmUtZm9ybSUyMiUyMGNsYXNzJTNEJTIydmFsaWRhdGUlMjIlMjB0YXJnZXQlM0QlMjJfYmxhbmslMjIlMjBub3ZhbGlkYXRlJTNFJTNDJTJGZm9ybSUzRSUwQSUwQSUzQyEtLUVuZCUyMG1jX2VtYmVkX3NpZ251cC0tJTNF" descr_space="eyJhbGwiOiIxNSIsImxhbmRzY2FwZSI6IjE1In0=" tds_newsletter="tds_newsletter3" tds_newsletter3-all_border_width="0" btn_text="Sign up" tds_newsletter3-btn_bg_color="#ea1717" tds_newsletter3-btn_bg_color_hover="#000000" tds_newsletter3-btn_border_size="0" tdc_css="eyJhbGwiOnsibWFyZ2luLWJvdHRvbSI6IjAiLCJiYWNrZ3JvdW5kLWNvbG9yIjoiI2E3ZTBlNSIsImRpc3BsYXkiOiIifSwicG9ydHJhaXQiOnsiZGlzcGxheSI6IiJ9LCJwb3J0cmFpdF9tYXhfd2lkdGgiOjEwMTgsInBvcnRyYWl0X21pbl93aWR0aCI6NzY4fQ==" tds_newsletter3-input_border_size="0" tds_newsletter3-f_title_font_family="445" tds_newsletter3-f_title_font_transform="uppercase" tds_newsletter3-f_descr_font_family="394" tds_newsletter3-f_descr_font_size="eyJhbGwiOiIxMiIsInBvcnRyYWl0IjoiMTEifQ==" tds_newsletter3-f_descr_font_line_height="eyJhbGwiOiIxLjYiLCJwb3J0cmFpdCI6IjEuNCJ9" tds_newsletter3-title_color="#000000" tds_newsletter3-description_color="#000000" tds_newsletter3-f_title_font_weight="600" tds_newsletter3-f_title_font_size="eyJhbGwiOiIyMCIsImxhbmRzY2FwZSI6IjE4IiwicG9ydHJhaXQiOiIxNiJ9" tds_newsletter3-f_input_font_family="394" tds_newsletter3-f_btn_font_family="" tds_newsletter3-f_btn_font_transform="uppercase" tds_newsletter3-f_title_font_line_height="1" title_space="eyJsYW5kc2NhcGUiOiIxMCJ9"]