How to export the contents of a Domino.Doc Library on the local file system? (part II)

This is the scond part of a two parts article.

The Cabinet documents created by the PopolaCabinets agent stores also the total binders numbers and the total documents number.
There are also two datetime fields used to store the start and the end time of the export.

The Cabinet form to store cabinet and binders info.

The EsportaCabinet agent

Here follows the code for the EsportaCabinet agent: is the agent that create the file system structure and populates it with the Domino.Doc attachments.

Continua a leggere

How to export the contents of a Domino.Doc Library on the local file system? (part I)

What You Need:

  • a PC running Lotus Notes, Lotus Notes Designer, a Domino.Doc Desktop Enabler full installation (with the Domino.Doc API), enough disk space to hold the exported documents;
  • a Lotus Notes id with full permissions for the Domino.Doc library (the Domino.Doc id administrator usually is fine);
  • the OpenLog, an open source application available on OpenNtf.org

Steps

  1. Download OpenLog on the local machine and configure a database to store the logs generated from exports.
  2. Download from the link (in the Part II post) the application edomdoc.nsf and store it in the data directory of the Lotus Notes client.
  3. Change the ACL of the database and sign the database with the ID notes above.
  4. Open the application edomdoc.nsf in the Notes Designer.
  5. Follow the instructions in the OpenLog database in order to enable logging in the edomdoc.nsf: the Script Library OpenLogClass and OpenLogFunctions are inside the edomdoc.nsf db, so you just need to change the line in the Sub Initialize with the right name of the OpenLog db you created above.
    logDbName = “OpenLog1_5Apache.nsf”
  6. Open the PopolaCabinets agent and modify the line 31 with the Lotus Notes id password and the line 32 with the path to the Domino.Doc server library (similar action is required for the EsportaCabinet agent).

Continua a leggere

Postjoin event example code for merging documents

You use a combination of custom attributes on the joining activity and code in the OS application event script library to get this to work. Below you will find some code and a brief description:

– Paste code below in the ‘PostJoin_’ event in the OS Application Events Script Library

– Add 2 Custom Attributes on the Merge Activity:

PostJoinMergeItems = “YES”;

Merge = array of fields to merge on the MainDoc

Private Function PostJoin_(Cover As NotesDocument,BinderCol As Variant)
Dim binder As Variant
Dim maindoc As NotesDocument
Dim doc As NotesDocument
Dim mainitem As NotesItem
Dim itemnames As Variant
Dim ErrorCode As Integer
Dim ErrorMsg As String
Dim k As Integer
Dim strFieldLabel As String
Dim curValue As String
Dim intModuleAlias As Integer
Dim arrVariant As Variant
Dim item As NotesItem
Dim RTitem As NotesRichtextitem
Dim RTitemMaindoc As NotesRichtextitem
Dim itemType As Integer
Dim intSaveMain As Integer

On Error Goto printError
' Get all documents in the binder
binder = DWFBinderGetDocumentList ( Cover )

' Identify the main document and check whether this code should run
Set maindoc = DWFBinderGetMainDocument ( Cover )

If (Ucase( maindoc.PostJoinMergeItems ( 0 )) = "YES" ) Then
	' Get the list of fields to merge
	itemnames = maindoc.Merge
	Forall b In binder
		' Only process documents that are not the main or cover document
		If Not (Ucase( b.CoverDocOS ( 0 )) = "YES" Or Ucase( b.MainDocOS ( 0 )) = "YES" ) Then
			Set doc = b
			' Check whether doc is a copy of the main document
			If DocsAreCopies ( maindoc , doc ) Then
				' Loop over all items that have to be merged
				Forall fieldName In Itemnames
					' eventuele niet parallele velden moeten appended worden onder het veld in het main-doc
					strFieldLabel = fieldName
					curValue = doc.getitemvalue( fieldName)(0)
					' Get the value from the item and append it to the item on the main document, without having to convert it to text
					If doc.HasItem( strFieldlabel ) Then
						'Let op ! Als het item wel op het doc staat en ook op het maindoc, dan overschrijft ..
						' .. dit de waarde op het main doc !! Daarom check op leeg !!!
						If Not curValue = "" Then
							Call maindoc.replaceItemValue( strFieldLabel, curValue )
							intSaveMain = intSaveMain + 1
						End If
					End If
				End Forall
				'save maindoc to still have reference to the old doc before deleting it
				If intSaveMain > 0 Then
					Call maindoc.Save (True, False)
				End If
				If DWFBinderConsolidate(doc, ErrorCode, ErrorMsg) Then
					' Remove this document from the binder and then delete it
					If DWFBinderRemoveDocument ( doc , False, "" , True, ErrorCode , ErrorMsg ) Then
						Call doc.replaceitemvalue( "RemoveStatus", "yes"  )
						Call doc.save(True,True,True)
						'Remove document later ....
						'Call doc.Remove(True)
					End If
				End If
			End If
		End If
	End Forall
	' Save the main document
	Call maindoc.Save (True, False)
End If
Exit Function

printError:
	Print "Error" & Str(Err) & ": " & Error$ & "Line=" & Erl
	Print "ERROR While joining"
	End Function

Function DocsAreCopies ( doc1 As Variant, doc2 As Variant) As Integer
%REM
this function compares the Modification History of two documents - if they have
the same anchestor the routine returns true otherwise it returns false
%END REM
Dim done As Integer
Dim char As String
Dim length As Integer
Dim i As Integer
Dim colonapeared As Integer
Dim modify1 As String
Dim modify2 As String
' get modify histories
modify1 = doc1 . DocModifyOS ( 0 )
modify2 = doc2 . DocModifyOS ( 0 )
' set len to the length of the shortest of both strings
If Len( modify1 )<Len( modify2 ) Then
	length = Len( modify1 )
Else
	length = Len( modify2 )
End If
i = 1
colonapeared = False
Do
	char =Mid( modify1 , i , 1 )
	If Not char = Mid( modify2 , i , 1 ) Then
		done = True
	Else
		If char = ";" Then
			colonapeared = True
		End If
		i = i + 1
	End If
Loop Until done Or colonapeared Or i > length
If colonapeared Then
	' both activities have a common predecessor
	DocsAreCopies = True
Else
	DocsAreCopies = False
End If
End Function

Domino.Doc

Oggi ero presso una importante azienda che produce articoli per la casa. Si è iniziato a lavorare su un workflow relativo alla intera fase di progettazione dei singoli prodotti. Dal briefing marketing, passando per la selezione del designer, il prototipo, l’analisi dei costi e arrivando al lancio della produzione. Un totale di 54 step formalizzati con tanto di task owner e finestre temporali.

La tecnologia che si intende utilizzare per l’implementazione del progetto è basta su IBM Lotus Domino Server con IBM Lotus Document Manager e IBM Lotus Workflow.

La scadenza del progetto è il 31 marzo 2007. Oggi abbiamo implementato lo step 0: abbiamo popolato un binder di un cabinet di Domino.Doc con i documenti relativi ai Requisiti Standard di Prodotto. Dobbiamo risolvere alcuni problemi relativi alla possibilità di usare tali documenti come bookmark tra filecabinet diversi: una possibile soluzione commerciale è quella di IIUI SmartBookmarking