Skip to content

Instantly share code, notes, and snippets.

@funkyboy
Last active August 29, 2015 14:12
Show Gist options
  • Select an option

  • Save funkyboy/ad3b25dfdbd53e27324f to your computer and use it in GitHub Desktop.

Select an option

Save funkyboy/ad3b25dfdbd53e27324f to your computer and use it in GitHub Desktop.
// This script endpoint: /plugin/addcar.bb
var capitalize = function(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
}
on('install',function(installEvent){
Box.DB.ensureCollection("cars");
return true;
});
http().post(function(req){
Box.log(req);
var name = req.body.name;
var capitalizedName = capitalize(name);
var c = Box.Documents.save("cars", {"name" : capitalizedName});
if (c) {
return {status: 200};
} else {
return {status: 500, content: "Error in saving car"};
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment