SeedCode Logo

a JavaScript approach to FileMaker Custom Web Publishing™

gh LogoDownload on GitHub

deleteRecordURL(fileName, layoutName, recid)

Create a FileMaker -delete query url by specifying the FileMaker record id. These queries are then passed to the postQueryFMS() function which returns the results as a single object array. The object contains the error code with "0" meaning a succesful delete.

Type: String
A String of the name of the hosted FileMaker file.
Type: String
A String of the name of the target layout in the specified file.
Type: number
The FileMaker Record ID (-recid) of the record to be deleted.
example 1
Create a -delete query by passing the -recid id to the function. Then POST the query. For this example we'll create a new record to delete (so we don't run out of sample data!)

//create new record query from object
var newRecord =	{
				"DateStart" : "02/25/2014" ,
				"DateEnd" : "02/25/2014" ,
				"Description" : "delete example" ,
				"Status" : "Open" ,
				"Summary" : "test delete example"
				} ;
var query = fmxj.editRecordURL("Events", "Events", newRecord);
fmxj.postQueryFMS(query, writeResult);//POST query
function writeResult (js) { // define handler for results.
	var record = js[0];
	updateElement("example1",JSON.stringify(js, null, 4));//write new record to element as JSON
	if(record["-recid"]){//this is the result for our new record.
	var recid = record["-recid"];//retrieve record id so we can delete it
	var dq = fmxj.deleteRecordURL("Events", "Events", recid );//create query
	fmxj.postQueryFMS(dq, writeResult);//POST query
	else//this is the result of our delete request so write it to element
	updateElement("example1", JSON.stringify(js, null, 4), true);