SeedCode Logo


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

gh LogoDownload on GitHub

findRecordsURL(fileName, layoutName,[ requests, sort, max, skip])

Create a complex xml -findquery string from an array of javascript objects. These queries are then passed to the postQueryFMS() function which returns the results as an array of JavaScript Objects (JSON).

fileName
Type: String
A String of the name of the hosted FileMaker file.
layoutName
Type: String
A String of the name of the target layout in the specified file.
requests
Type: Array of Objects
(Optional) An Array of Objects where each object represents a FileMaker Find Request. If this arguement is not passed then a -findall query will be generated.

sort
Type: Object
(Optional) An Object of name value pairs specifying a sort order for the query. Supported properties are field1-fieldn and order1-ordern (see example 3 below).
max
Type: Number
(Optional) A Number specifying the maximimum number of parent records to be returned from FileMaker Server. Simmilar to Fetch First in FileMaker's SQL syntax.
skip
Type: Number
(Optional) A Number specifying the number of records to skip in the found set before starting to return them. Simmilar yo Offset in FileMaker's SQL Syntax.
example 1
Two request find query for the layout "Events" in the file "Events".

var requests =	[
	{ "DateStart" : "<=2/28/2014" , "DateEnd" : ">=2/1/2014" } ,
	{ "DateStart" : "2/1/2014...2/28/2014" }
				];	
var query = fmxj.findRecordsURL("Events", "Events", requests) ;


		
example 2
Add additional criteria to requests object, so both requests have the Resource field equal to "Example C".

var requests =	[
	{ "DateStart" : "<=2/28/2014" , "DateEnd" : ">=2/1/2014" },
	{ "DateStart" : "2/1/2014...2/28/2014" }
			   	];
requests[0]["Resource"] = "Example C";
requests[1]["Resource"] = "Example C";
var query = fmxj.findRecordsURL("Events", "Events", requests);


		
example 3
Specify a sort order for the request by passing an object to the optional sort argument. Supprted order values are: ascend, descend and valuelist.

var requests =	[
	{ "DateStart" : "<=2/28/2014" , "DateEnd" : ">=2/1/2014" } ,
	{ "DateStart" : "2/1/2014...2/28/2014" }
				] ;
var sort =	{ 
			"field1" : "DateStart" ,
			"order1" : "descend" ,
			"field2" : "id" ,
			"order2" : "ascend"
			} ;
var query = fmxj.findRecordsURL("Events", "Events", requests, sort) ;


		
example 4
Specify an Omit Request by setting the -omit property to 1.

var requests =	[
	{ "DateStart" : "<=2/28/2014" , "DateEnd" : ">=2/1/2014" } ,
	{ "DateStart" : "2/1/2014...2/28/2014" } ,
	{ "Resource" : "Example B" , "-omit" : "1" }
				] ;
var query = fmxj.findRecordsURL("Events" ,"Events" ,requests) ;