Add Camera Photo support
Download Camera Sample
- To take a new photo and link the photo to an existing database
record, just call the App.takePicture(linkedtable, linkedid) method
- To list all photos linked to a given record, make a select query on the the system.files table.
- To view an existing photo, start the Upvise Files standard App, with Files.viewFile(fileid) method.
- Because photos & files are stored in a the system.files table, there is no need to add a new column in your SQL table.
- Make sure you use the fully qualified name appid.tablename for the linkedtable parameter for App.takePicture() emthod
- Make sure to add Config.uses="Files"; at the top of your code to reference the Upvise Files app. Required to call Files.viewFile(fileid) method
Config.appid = "myappid";
Config.uses = "Files"; // need this to make a call for the Standard File app to view the photo.
Config.tables["leads"] = "id;name";
function viewLead(id) {
var lead = Query.selectId("leads", id);
Toolbar.setTitle("Lead Info");
List.addItemTitle(lead.name);
List.addButton("Add Photo", "App.takePicture('myappid.leads',{id})");
var files = Query.select("system.files", "id;name;date", "linkedtable='myappid.leads' AND linkedrecid={id}", "date");
List.addHeader("Photos (" + files.length + ")");
for (var i = 0; i < files.length; i++) {
var file = files[i];
var img = Settings.getFileUrl(file.id);
List.addItem(Format.datetime(file.date), "Files.viewFile({file.id})", "scale:crop;img:" + img);
}
List.show();
}