Ultimate JSON Part 1
If you're developing in FileMaker and haven't invested time in learning and using JSON, you're at a significant disadvantage. JSON is not difficult to learn, and it's used in so many areas of modern development that it's crucial to get familiar with it if you haven't already.
In this video, I begin with the basics of JSON and its implementation within FileMaker. Once you start using it, you'll find it's valuable for much more than just passing parameters. While passing parameters is one of the most common use cases — allowing you to pass multiple values easily — JSON also supports a wide range of applications, from creating UI features to saving the state of tabs, layouts, user preferences, and even capturing metadata about your stored data.
Additionally, many advanced FileMaker features, like web viewers, rely on JavaScript and JSON for functionality. As you explore data exchange between applications, you'll see JSON frequently in modern APIs as well.
Make sure to take full advantage of this multi-part video series, where I'll cover the various ways you can leverage JSON within FileMaker. This knowledge will significantly expand what you can do with the platform.
- Read more about Ultimate JSON Part 1
- 1 comment
- Log in or register to post comments
JSON Set Variable Power Tools
Our world of software development is changing rapidly! With AI influencing the way we develop, it becomes increasingly important for developers to become informed about the tools which help them become more efficient.
Fortunately, we still live in a world where people have to coordinate and organize code. Even if AI can create near-flawless code in some cases, it doesn't create the ideas. Humans are the creative force. Whether you're using a simple Find & Replace to refactor some functions, or having AI create your next powerful JavaScript for your killer Web Viewer interactions, you still need to know about your available tools.
In this video, I walk you through a recent revision to an older tool I had been using to ease the amount of typing I have to do when using JSON as the parameter passing method within FileMaker scripts or when interacting with an API or anything else that uses JSON. No joke, the content in this video and the associated technique file can save you literally hundreds of hours when used effectively. I'll show you how.
- Read more about JSON Set Variable Power Tools
- 3 comments
- Log in or register to post comments
Exporting JSON
JSON, JSON, JSON! If you haven't gotten used to it yet, you'd better start. It's the way you communicate with the web. It's the structure that's winning. XML is too verbose, and .tab and .csv aren't always clear enough.
So, what are some of the ways you can create JSON within FileMaker? Here are just a few:
1. Create a calculated field of it.
2. Use ExecuteSQL() to return it.
3. Use Execute FileMaker Data API [ ].
4. Write a looping script.
5. Or... you can just export it.
This last method is often the most optimal for getting your data into the JSON format to meet whatever requirements you may have. You can further modify this JSON using a variety of tools to achieve the perfect result.
In this video, and the associated technique file, I provide the knowledge and code necessary to simply export your data as JSON and be done with it. No matter what you need and where you need it, you can use multiple exports from however many tables desired to end up with the needed JSON result.
- Read more about Exporting JSON
- Log in or register to post comments
JSON Parameter Passing
Thank goodness JSON was implemented within FileMaker. Without it, we would still be using a variety of other methods for handling multiple parameters within a FileMaker script. Using JSON, we now get the double-sided benefit of 1) having an efficient serialization of key/value pairs as inbound parameters and 2) it just happens to be the standard which most of the rest of world is using for a large chunk of how things interoperate.
In this video, and the technique file, I'll showcase a few examples of how you can receive and work with inbound parameters when using JSON as the method for handling them. We discuss script results, clean-reading code and the final example provides a very useful custom function for the auto-instantiation of JSON-based script parameters into their FileMaker scripting counterparts.
Using the provided JSONVariables custom function is a great alternative to individually parsing all of the inbound parameters. It doesn't replace the need to initially declare your variables, but it does provide the opportunity to have cleaner reading self-documenting code. If you've not used JSON for handling your parameters before, then you should start right now and use this video and file as guidance!
- Read more about JSON Parameter Passing
- 3 comments
- Log in or register to post comments
JSON Manipulation using JSONata
Having created recent videos about accessing APIs via REST, and extracting the free JSON data as well, it would be a glaring omission if I didn't address our need to manipulate the JSON FileMaker provides us with. Yes, the work to put your FileMaker data into structured JSON has already been done. But, the JSON you need for your designated API is always going to be different than that.
Fortunately, we have access to the amazingly powerful and fast JavaScript engine built into each and every Web Viewer. What we need to capitalize on are the free open source libraries which help us get the results we need.
JSONata is a long standing powerhouse when it comes to manipulating JSON within JavaScript. Updates as recently as two years ago, to the eight year old library, moved it from a more linear synchronous model to an async model. This means we need to learn a bit about JavaScript promises and how we can use JSONata's own tools to easily manipulate our FileMaker JSON into what's needed. This video and the associated technique file will provide you with the tools which will help accomplish the integrations you're trying to solve.
- Read more about JSON Manipulation using JSONata
- 3 comments
- Log in or register to post comments
Easy JSON Record Data
Coding software solutions offers the fascinating realization that there are always multiple pathways to achieve the same goal. Sometimes the methods we're familiar with may not be the most optimal, prompting us to expand our knowledge to explore alternative approaches.
This video explores precisely that theme - the comparison between older and newer methods of accomplishing the same task. The advantage lies in the fact that newer methods often come with additional features or benefits. This is particularly true when it comes to obtaining the current record data as a JSON object. Historically, we've relied on ExecuteSQL to extract field names and values from the current record or a set of records.
In this video, I delve into the existing options using ExecuteSQL for creating a JSON object of the current record data. This method is effective in various scenarios. However, accessing related data can be time-consuming, especially when constructing SQL joins accurately requires significant mental effort. Unless you're a SQL expert, this may not be the most efficient use of your development time. Fortunately, recent versions of FileMaker have streamlined the process, making it exceptionally easy, with an alternative method, to extract any data from any record and convert it into the precise JSON object needed for passing parameters or interacting with external APIs.
- Read more about Easy JSON Record Data
- 10 comments
- Log in or register to post comments
Virtual List JSON Portal Filtering
Developing software in FileMaker can be such a joy when you're able to solve so many problems so quickly. There is, however, a point where you start to solve so many problems that your solution starts to slow down and you find yourself wondering why.
Most commonly, it's the result of cumulative features compounding to make your solution slower and slower. Without careful consideration of the user interface, and how features are presented, it's easy to create a solution which starts to lag over time.
In this video, I show how portal filters really work and how to address the issue of a portal used for a very simple selection process. In most cases, your portal is only going to show a fraction of the number of fields found in its table. To this end, you must learn how to replicate the native portal filtering feature. Filtering with JavaScript/JSON is one of the most powerful ways to present data in both an efficient and faster way.
Finding your FileMaker solution is feeling slower as time goes by? You need the content covered in this video!
- Read more about Virtual List JSON Portal Filtering
- 13 comments
- Log in or register to post comments
Learning JavaScript in FileMaker
Some developers who start with FileMaker never extend beyond it. Hopefully, that's not you. Or, at least you're willing to look into learning some other languages and see how they can benefit your FileMaker solutions!
In FileMaker 19 we gained both a new script step named "Perform JavaScript in Web Viewer" and a JavaScript function embedded into the Web Viewer named "FileMaker.PerformScript()". If you haven't taken the time to investigate how these new features work, then allow me to give you the gentle push into taking advantage of them.
While formerly we could use a plug-in to directly execute JavaScript, and there were some "hackish" workarounds to using the JavaScript within Web Viewers, we now have a totally native way to take advantage of this very powerful technology. Understanding how things work, and what you can do, will expand your development capabilities. I highly suggest you take a serious look at learning a bit of JavaScript and the cool thing is you can do it right within a FileMaker file!
- Read more about Learning JavaScript in FileMaker
- 3 comments
- Log in or register to post comments
Validating JSON for Scripts
Using JSON for passing multiple parameters can be a real life saver. Because JSON keeps all individual parameters separate from each other, you can pass pretty much any type of data except for container data - although you can pass a reference to a container easily enough. Your parameters can also have as many levels as necessary and the JSON can easily be modified as it moves from script to script.
When writing a complex and large collection of scripts, you eventually hit errors and issues. You end up spending extra time hunting down problems and eventually you find out it's a simple issue where you just "forgot" to include that one additional item the script needed in order to handle the process properly.
This is where validation comes into play. It's a perfect solution for making sure your scripts work the way you expect them to. Rather than letting the script fail, then determining whether it really did fail or not, you're telling the script it MUST fail unless it has all the required parts.
Thus, a single script, with a multi-dimensional JSON validator is a wonderful tool to have for your complex scripting situations. In the associated video and technique file, you'll find a complex script which will save hours and hours of time by validating your JSON data before the script even tries to use it.
- Read more about Validating JSON for Scripts
- 1 comment
- Log in or register to post comments
Detecting Data Changes
Here's an interesting dilemma. How do you track when specific fields are modified and adjust your JSON object so it only includes the data which was modified? Or, how about knowing when a user has modified specific fields, then having the user interface direct them down a different path than if they had modified others?
In both situations, you simply need to know when a field was modified. Using the Get ( RecordModificationCount ) function we can know THAT a given record was modified and using a modification field we can know WHEN it last happened. What we don't know is when only a specific set of fields is modified. We also may need to know exactly which fields were modified in order to take some type of action. This is where Detecting Data Changes is quite helpful. There are a number of ways this can be accomplished and the solution, as always, depends on what your needs are.
In this video, I showcase a method I use to detect data changes and then generate a JSON object based on specific fields which were changed. If you find your solution needing to work with an external API or needing to simply know when certain fields have been changed then you're sure to find some valuable info within this video and technique file.
- Read more about Detecting Data Changes
- 2 comments
- Log in or register to post comments