Lesterius is a European Claris (FileMaker) Business Alliance Platinum member that operates in Belgium, France, the Netherlands, Portugal and Spain. We are creative business consultants who co-create FileMaker Platform based solutions with our customers.
Sharing knowledge takes part of our DNA, that's why we developed this library to make the FileMaker Data API easy-to-use with Javascript.
Break the limits of your application!
This library is a Javascript wrapper of the (Claris) FileMaker Data API 19.
You can find the PHP wrapper of the FileMaker Data API 18 here
You can find the Javascript wrapper of the FileMaker Data API 18 on the releases <= v.1.* .
You will be able to use every functions like it's documented in your FileMaker server Data Api documentation (accessible via https://[your server domain]/fmi/data/apidoc). General Claris document on the Data API is available here
The recommended way to install it is through Composer.
composer require myfmbutler/myfmapilibrary-for-js
After installing, you can call this javascript library by adding:
<script src="DataApi.js"></script>
In your html file.
- Enable the FileMaker Data API option on your FileMaker server admin console.
- Create a specific user in your FileMaker database with the 'fmrest' privilege
- Define records & layouts access for this user
Login with credentials:
let options = {
'apiUrl': 'https://test.fmconnection.com/fmi/data',
'databaseName' : 'MyDatabase',
'login' : 'filemaker api user',
'password' : 'filemaker api password'
};
let api = new DataApi(options);
Login with oauth:
let options = {
'apiUrl': 'https://test.fmconnection.com/fmi/data',
'databaseName' : 'MyDatabase',
'oAuthRequestId' : 'oAuthIdentifier',
'oAuthIdentifier' : 'oAuthIdentifier'
};
let api = new DataApi(options);
Use only generated token:
let options = {
'apiUrl': 'https://test.fmconnection.com/fmi/data',
'databaseName' : 'MyDatabase',
'token' : 'generated token'
};
let api = new DataApi(options);
To re generate a token, use 'login' function.
/!\ Not available with 'Login with token' method, use 'setApiToken' function.
dataApi.logout();
dataApi.validateSession();
let data = {
'FirstName' : 'John',
'LastName' : 'Doe',
'email' : 'johndoe@acme.inc'
};
let scripts = [
{
'name' : 'ValidateUser',
'param' : 'johndoe@acme.inc',
'type' : SCRIPT_PREREQUEST
},
{
'name' : 'SendEmail',
'param' : 'johndoe@acme.inc',
'type' : SCRIPT_POSTREQUEST
}
];
let portalData = {
'portalName or OccurenceName' : [
{
"Occurence::PortalField 1" : "Value",
"Occurence::PortalField 2" : "Value",
}
]
};
let recordId = dataApi.createRecord('layout name', data, scripts, portalData);
dataApi.deleteRecord('layout name', recordId, script);
let recordId = dataApi.editRecord('layout name', recordId, data, lastModificationId, portalData, scripts);
let recordId = dataApi.duplicateRecord('layout name', recordId, scripts);
let portals = [
{
'name' : 'Portal1',
'limit' : 10
},
{
'name' : 'Portal2',
'offset' : 3
}
];
let record = dataApi.getRecord('layout name', recordId, portals, scripts);
let sort = [
{
'fieldName' : 'FirstName',
'sortOrder' : 'ascend'
},
{
'fieldName' : 'City',
'sortOrder' : 'descend'
}
];
let record = dataApi.getRecords('layout name', sort, offset, limit, portals, scripts);
let query = [
{
'fields' : [
{'fieldname' : 'FirstName', 'fieldvalue' : '==Test'},
{'fieldname' : 'LastName', 'fieldvalue' : '==Test'},
],
'options' : {'omit': false}
}
];
let results = dataApi.findRecords('layout name', query, sort, offset, limit, portals, scripts, responseLayout);
let data = {
'FieldName1' : 'value',
'FieldName2' : 'value'
};
dataApi.setGlobalFields('layout name', data);
dataApi.executeScript('script name', scriptsParams);
dataApi.uploadToContainer('layout name', recordId, containerFieldName, containerFieldRepetition, file);
dataApi.getProductInfo();
/!\ Not available with 'Login with token' method
dataApi.getDatabaseNames();
dataApi.getLayoutNames();
dataApi.getScriptNames();
dataApi.getLayoutMetadata('layout name', recordId);