2

I need to read a property from database: Template version is.

I have tried:

  1. Checked NotesDatabase classes (LS and Java) and have not found quickly anything.
  2. Checked at catalog.nsf and still could not see that value.

Does anybody know how to do that? Thanks.

enter image description here

Per Henrik Lausten
  • 21,331
  • 3
  • 29
  • 76
Dmytro Pastovenskyi
  • 5,240
  • 5
  • 37
  • 56

1 Answers1

6

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();
}
Per Henrik Lausten
  • 21,331
  • 3
  • 29
  • 76
  • 1
    Works, thanks! I have checked About, Using, Database icon and DatabaseScript documents. Could not even believe it would be stored in shared fields, does not make sense for me. – Dmytro Pastovenskyi Oct 27 '20 at 13:26