Skip to content

Instantly share code, notes, and snippets.

@toddgeist
Last active August 29, 2015 14:24
Show Gist options
  • Save toddgeist/13157485b81f3e2b985e to your computer and use it in GitHub Desktop.
Save toddgeist/13157485b81f3e2b985e to your computer and use it in GitHub Desktop.
Running a FileMaker Script with sails-filemaker
/**
* ContactController
*
* @description :: Server-side logic for managing Contacts
* @help :: See http://sailsjs.org/#!/documentation/concepts/Controllers
*/
module.exports = {
/**
* Custom endpoint - by default it will be available at
*
* http://<server>:<port>/Contact/runScript
*
* @param req
* @param res
*/
runScript : function (req, res) {
/*
we can call a script by adding '-script' : scriptname to any query
in this case we add it to a find.
this is true for any of the FileMaker XML publishing params.
sails-filemaker treats them as data or criteria and will pass them on to FileMaker
FileMaker interprets them correctly.
Below we use '-script' and '-script.param'.
you will need to give it some find criteria, even if you don't care about the find
*/
var criteria = {
'firstName' : "*",
'-script' : 'my script',
'-script.param' : 'my script parameter'
};
Contact.find(criteria).exec(function(err, results){
if(err) return res.json(err)
res.json(results);
})
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment