Call FileMaker Script from a JavaScript function

This article is the second part of a two-part series diving into some new features of FileMaker 19. In the previous article (https://www.metasyssoftware.com/blogs/integrating-jquery-datatable-in-filemaker-application-using-perform-javascript-in-web-viewer), we explored the new FileMaker script step “Perform JavaScript in Web Viewer”. Using this feature, we added the jQuery data table in FileMaker Web Viewer. In this article, we will explore how we can call a FileMaker script from JavaScript function within FileMaker Web Viewer.

Demonstration

The example we will be using is a follow-on from the previous article, in which we showed a method for displaying data of companies and contacts. We displayed the FileMaker data in a jQuery datatable in the FileMaker Web Viewer, which allowed us to include jQuery features like pagination and sorting without any coding. Using the FileMaker.PerformScript() function, we can add the functionality through which, once the user clicks on any of the contact records from datatable in Web Viewer, the chosen contact details are shown on the FileMaker card window.

Inventory_19

The FileMaker.PerformScript() function takes two input parameters:

  1. FileMaker Script Name – A non-case-sensitive name of the script we wish to run
  2. Script input parameters (optional) – a string that contains the required parameters, which can be read using the function Get(ScriptParameter).

This FileMaker script can be called from the WebViewer using the following JavaScript function: function performFileMakerScript() {
FileMaker.PerformScript ( “FileMaker Script Name”, “Optional Parameter” );

Specify calculation

The highlighted section from the above screenshot shows how to call the FileMaker script using ‘FileMaker.PerformScript() function from Web Viewer. In it we write a JavaScript function called showContacts(), in which we can specify the execution for a double click event. We specify that a double click event calls the FileMaker script called “Show Contact Details”, passing the ID parameter as the optional second parameter. The ID parameter is retrieved from the double click event, by identifying the datatable row that has been clicked. This id parameter is further used in the FileMaker script to get more details of the selected contact record and displayed in the FileMaker card window.

A few notes regarding this implementation:

  • In the Web Viewer Setup dialog, you must select the setting “Allow JavaScript to perform FileMaker scripts”. Otherwise, the FileMaker.PerformScript()function will not work.
  • The FileMaker script name which we pass as a first parameter is not case-sensitive.
  • The FileMaker.PerformScript() function doesn’t wait for the FileMaker script to finish. That means the FileMaker script doesn’t return a value to the FileMaker.PerformScript() function that called it.
  • The FileMaker script is executed in the current context. So if the user or script changes the layout or record while the script is running, then the FileMaker script will run in a new context. To deal with such a situation, we can pass the context information as a second parameter to the function.

The JavaScript integration in FileMaker 19 platform allows creating custom apps that can use the existing JavaScript libraries to incorporate amazing functionality easily. It enables a seamless ability to pass data back and forth between FileMaker and JavaScript.

If you are looking for support with FileMaker, or FileMaker integration, feel free to contact our us. For more details, please visit – www.metasyssoftware.com/filemaker

Integrating jQuery datatable in FileMaker application using Perform JavaScript in Web Viewer

In a previous blog, we described the new exciting features of FileMaker 19. One of these features is the new ‘FileMaker JavaScript Web Viewer Integration’. Using this feature, we can establish  smooth communication between FileMaker and Web Viewers. This allows us to extend the functionality of FileMaker systems with features which are not native to FileMaker.

Claris FileMaker 19 introduced a new script step called “Perform JavaScript in Web Viewer,” and JavaScript function, FileMaker.PerformScript(). Using this we can use the features which are readily available in JavaScript in FileMaker.

In this blog article, we will explore the “Perform JavaScript in Web Viewer” script step. Using this new feature, we are adding the jQuery datatable in our FileMaker application.

Demonstration

In our FileMaker application, we have a list of companies and their contacts. On the company list layout we display the list, and for selected companies, we display their contacts in the jQuery datatable. Using jQuery debatable, we get all the inbuilt features available with it. For e.g. We get the sort, search functionality and pagination. We don’t have to write separate code in FileMaker !

Please see the below screenshot

Inventory_19

Let’s take a look at how we can achieve this in FileMaker application.

  • Add a web viewer on the layout and give it a name.
  • Embed the JavaScript function/code as a calculation result in the Web Viewer.

Specify calculation

The screenshot above displays a JavaScript function called “showContacts” that performs the following:

  • Accept one parameter from FileMaker script.
  • Format the parameter in a proper format.
  • Create the datatable and pass the above parameter as data to it.

In the Web Viewer, also add all the JavaScript libraries required for datatable.

Now create the script in FileMaker with “Perform JavaScript in Web Viewer” script step. This script  will call the JavaScript function that we wrote in the web viewer. In this script, create the data in JSON format, and pass this as a parameter to the JavaScript function.  Please refer to the screenshot below.

Perform Javascript in web viewer

Using this new FileMaker feature, we can work on the functionalities which are readily available in JavaScript in our FileMaker application.

If you are looking for support with FileMaker, or FileMaker integration, then feel free to contact our FileMaker certified developers. For more details, please visit –https:// www.metasyssoftware.com/filemaker

 

Publish Product data from FileMaker solution to Shopify store

This blog article describes a simple way to integrate Shopify and Filemaker. Shopify is a popular ecommerce platform used by many businesses around the world, and integrating Shopify and FileMaker can save time and money.

FileMaker integration is made easy due to two powerful features. Firstly, the enhanced cURL options which make it easy to interact with many systems by facilitating many common file transfer options. Secondly, the native functions to create and extract data from JSON, which makes interactions with web services easy. These features allow FileMaker to be integrated with almost any third party products that provide the APIs for communication, including Shopify.

Step One: Create a private app in the Shopify account.

  • We can connect to a Shopify account by creating a private app. Shopify requires an API Key, the API password of the private app, and the store name for authentication.
  • The screenshot below shows how to create a Private app and how to get the API key and API password.

FM Shopify demo image 1

  • Give the appropriate API permissions required by your private app.
  • As described in the Shopify documentation, Shopify authenticates private applications using the following URL format: https://{apikey}:{password}@{hostname}/admin/api/{version}/{resource}.json

Note that the ‘hostname’ refers to the store name, and ‘version’ refers to the API version in use.

Step Two: Store the required Shopify details in FileMaker

  • In the FileMaker database, create the fields to store the API Key, API Password, Store Name and API Version, as shown in the screenshot below.

Shopify details 2

Step Three: Write the script

  • Write a script in FileMaker which will create the product in the Shopify account using the Shopify details mentioned in Step 2. For this step, we will use the cURL and JSON features of FileMaker.
  • In the script, first create the JSON array with Product details such as Product Title, Product Description, Vendor etc.
  • Next, format the URL (using the URL format mentioned in Step 1) with your Shopify account details. Then use this URL in the FileMaker ‘Insert from URL’ script step and pass the JSON array using the cURL option in it.
  • Please see the below screenshot for reference.

Script workspace image 3

After these three steps, we are ready to publish our product from a FileMaker database to a Shopify account. If you are experiencing issues with FileMaker, or FileMaker integration, feel free to contact our FileMaker certified developers. For more details, please visit – https://www.metasyssoftware.com/filemaker