I need to read a property from database: Template version is.
I have tried:
Does anybody know how to do that? Thanks.
Here's a handy code snippet to get the template version using Java:
private static String getVersionNumber(Database db) {
NoteCollection noteCollection;
noteCollection = db.createNoteCollection(true);
noteCollection.setSelectSharedFields(true);
noteCollection.setSelectionFormula("$TITLE=\"$TemplateBuild\"");
noteCollection.buildCollection();
final String noteID = noteCollection.getFirstNoteID();
final Document designDoc = db.getDocumentByID(noteID);
return designDoc.getItemValueString("$TemplateBuild");
}
Similarly you can get the template build date:
private static Date getBuildDate(Database db) {
NoteCollection noteCollection;
noteCollection = db.createNoteCollection(true);
noteCollection.setSelectSharedFields(true);
noteCollection.setSelectionFormula("$TITLE=\"$TemplateBuild\"");
noteCollection.buildCollection();
final String noteID = noteCollection.getFirstNoteID();
final Document designDoc = db.getDocumentByID(noteID);
return ((DateTime) designDoc.getItemValueDateTimeArray("$TemplateBuildDate").get(0)).toJavaDate();
}