SeedCode Logo


fmxj.js
a JavaScript approach to FileMaker Custom Web Publishing™

gh LogoDownload on GitHub

filterObjects(filters, searchTypes, source)

Apply complex property filters to an array of objects in JSON format using the request syntax.

filters
Type: Array of Objects
An Array of Objects where each object represents a FileMaker type Find Request, i.e. each property specified within an object represents an AND clause and each object on the array represents an OR clause.
searchTypes
Type: Object
An Object specifying the standard search types to apply when filtering by the specified property. Supported search types are:
source
Type: Array of Objects
The Array of Objects to be filtered.
example 1
Get an array of objects from the server and then apply and revert filters to it.

var source = [];
var requests =	[
	{ "DateStart" : "<=2/28/2014" , "DateEnd" : ">=2/1/2014" } ,
	{ "DateStart" : "2/1/2014...2/28/2014" }
				] ;
var query = fmxj.findRecordsURL("Events", "Events", requests) ;
fmxj.postQueryFMS(query, writeResults);
function writeResults(js){
	source=js;
	var display = source.splice(0,500);
	document.getElementById("example1").innerHTML=JSON.stringify(display, null, 4);
};
Apply filters

var requests = [
	{ "id" : "E4B04F12-E006-4928-A1E0-0E86EDF5641C" } , 
	{ "id" : "463BBEA9-404B-4979-8CC0-6F8F60EB0154" } ,
	{ "id" : "8CDA64C4-643D-4A64-9336-83BEF07F0CF4" } ,
			   ];
var types = {"id" : "equals"};
filter = fmxj.filterObjects(requests, types, source);
document.getElementById("example1").innerHTML=JSON.stringify(display, null, 4);