Template version

I saw that, on 6.0.1, you can display the template VERSION on the db infobox: VERY interesting, BUT where do you supply this information? or where does it come from?

Subject: Template version

Hi Francesco, any news on this issue?

Does anybody know if it is available to programmers/designers or only to Lotus internal use…

Tanks,

JR

Subject: RE: Template version

$TemplateBuild… - access only by Notes hack… (hack by LotusScript is possibile)

Subject: RE: Template version

Do you know how to do this using LS?

Is it available from the Notes API?

Subject: Here’s some LS code for retrieving it

Dim session	As NotesSession

Dim db	As NotesDatabase

Dim nc	As NotesNoteCollection

Dim doc	As NotesDocument

Dim iCount	As Integer

Dim sNoteID	As String



Const ITEM_BUILD_NAME	= "$TemplateBuild"

Const ITEM_BUILD_DATE	= "$TemplateBuildDate"



Set session	= New NotesSession

Set db	= session.CurrentDatabase

Set nc	= db.CreateNoteCollection(False)



If Not nc Is Nothing Then

	

	nc.SelectSharedFields = True

	Call nc.BuildCollection

	

	sNoteID = nc.GetFirstNoteId

	For iCount = 1 To nc.Count

		Set doc = db.GetDocumentByID(sNoteID)

		If Not doc Is Nothing Then

			If doc.HasItem(ITEM_BUILD_NAME) Then

				Msgbox "Version: " & doc.GetItemValue(ITEM_BUILD_NAME)(0)

				Msgbox "Date: " & doc.GetItemValue(ITEM_BUILD_DATE)(0)

				Exit For

			End If

		End If

		sNoteID = nc.GetNextNoteID(sNoteID)

	Next iCount

	

End If

Subject: Here’s some LS code forsetting it

Simple but it works!

Sub Initialize

Dim session As NotesSession

Dim db As NotesDatabase

Dim nc As NotesNoteCollection

Dim doc As NotesDocument

Dim iCount As Integer

Dim sNoteID As String



Const ITEM_BUILD = "$TemplateBuild"

Const ITEM_BUILD_NAME = "$TemplateBuildName"

Const ITEM_BUILD_DATE = "$TemplateBuildDate"



Set session = New NotesSession

Set db = session.CurrentDatabase

Set nc = db.CreateNoteCollection(False)



If Not nc Is Nothing Then

	

	nc.SelectSharedFields = True

	Call nc.BuildCollection

	

	sNoteID = nc.GetFirstNoteId

	For iCount = 1 To nc.Count

		Set doc = db.GetDocumentByID(sNoteID)

		If Not doc Is Nothing Then

			If doc.HasItem(ITEM_BUILD) Then

				Call doc.ReplaceItemValue(ITEM_BUILD_NAME, Inputbox$ ("Enter the template name...", "Template Name", doc.GetItemValue(ITEM_BUILD_NAME)(0)))

				Call doc.ReplaceItemValue(ITEM_BUILD, Inputbox$ ("Enter the version number...", "Template Version", doc.GetItemValue(ITEM_BUILD)(0)))

				Call doc.ReplaceItemValue(ITEM_BUILD_DATE, Cdat(Inputbox$ ("Enter the version date...", "Template Date", doc.GetItemValue(ITEM_BUILD_DATE)(0))))

				Call doc.Save(True, False)

				Exit For

			End If

		End If

		sNoteID = nc.GetNextNoteID(sNoteID)

	Next iCount

	

End If

End Sub

Subject: Nice code Thomas. Had not yet had a chance to play with the NotesNoteCollection class.

Subject: Should be able to set it in LS

Just need to get a handle on the form (using techniques such as GetDocumentByUNID after getting UNID or see Sendbox for DBDesign class) and set the value using doc.~$TemplateBuild