Search code examples
xpageslotus-noteslotus-dominolotusscript

Read "Template version is" from database


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


Solution

  • 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();
    }