Problem with ComposeDocument

Hello, I create the foillowing Document-Action and get a Problem.

This script copy some adress information from my databasedocuments to a notes-adressbook.

When I use the regular adressbook (Names.nsf) all work fine without any problem,

but when I use a new adressbook (secound adressbook), created from the pernames.ntf template, the script run without problems as long as the new adressbook opened the first time after the copy.

When I use the Actionbutton after the new adressdatabase was open notes goes to a ‘spinloop’

and the only way to stop this, kill the notes prozesses.

Add information, when I open the new adressbook after the copy. the About Document of this DB

will be displayed the first time.

I try the script in a Agent, too → same problem…

any hints are welcome.

Regards Lars

    Dim sworkspace As New NotesUIWorkspace 

    Dim tworkspace As New NotesUIWorkspace 

    Dim suidoc As NotesUIDocument         

    Dim tuidoc As NotesUIDocument 

    Dim tdb As NotesDatabase 

    Dim session As New NotesSession 

    Dim kunde As String 

    Dim kundelang As String 

    Dim stra As String         

    Dim plz As String 

    Dim ort As String 

    Dim phone As String 

    Dim dirfn As String 

    Dim answer As Integer         

    Dim inputstring As String 

    

    Set suidoc = sworkspace.CurrentDocument 

    

    kunde = suidoc.FieldGetText( "Adres" )         

    kunde = Replace(kunde,"ß","ss") 

    kunde = Replace(kunde,"ä","ae") 

    kunde = Replace(kunde,"ü","ue") 

    kunde = Replace(kunde,"ö","oe") 

    kundelang = suidoc.FieldGetText( "Adres_1" )         

    kundelang = Replace(kundelang,"ß","ss") 

    kundelang = Replace(kundelang,"ä","ae") 

    kundelang = Replace(kundelang,"ü","ue") 

    kundelang = Replace(kundelang,"ö","oe") 

    stra = suidoc.FieldGetText( "Adres_2" )         

    stra = Replace(stra,"ß","ss") 

    stra = Replace(stra,"ä","ae") 

    stra = Replace(stra,"ü","ue") 

    stra = Replace(stra,"ö","oe") 

    plz  = suidoc.FieldGetText( "Adres_3" )         

    ort = suidoc.FieldGetText( "Adres_4" )         

    ort = Replace(ort,"ß","ss") 

    ort = Replace(ort,"ä","a") 

    ort = Replace(ort,"ü","u") 

    ort = Replace(ort,"ö","o") 

    phone = suidoc.FieldGetText( "Adres_5" )         

    

    

    inputstring = "Please Enter the Filename of the used Adressbook w/o .NSF (e.g. FFATAdres)"_ 

    & Chr$(13) & "If you use the Primary Notes Adresbook enter 'NAMES' w/o .NSF,  "_ 

    & Chr$(13) & "but it's recommended to use a separat adressbook. " & Chr$(13) & " " 



    dirfn = Inputbox(inputstring,"Get Adressdatabase") 



    If Ucase$(dirfn) = "NAMES" Then 

            answer% = Messagebox("... Adress BookTitle   <-   Is this the correct DB?", 4, "Database Name") 

            If answer <> 6 Then Goto ende 

            Set tuidoc = tworkspace.ComposeDocument( "", "names", "Person" ) 

    Else         

            Dim dbchk As New NotesDatabase("","..\notes\data\"& dirfn) 

            If dbchk.Title= "" Then Goto notvalid 

            answer% = Messagebox(dbchk.Title & " <-   Is this the correct DB?", 4, "Database Name") 

            If answer <> 6 Then Goto ende 

            Set tuidoc = tworkspace.ComposeDocument( "", "..\notes\data\"&dirfn, "Person",,False )         

    End If 

    

    tuidoc.ExpandAllSections 

    tuidoc.FieldSetText "LastName", kunde 

    tuidoc.FieldSetText "CompanyName", kundelang 

    tuidoc.FieldSetText "OfficeStreetAddress", stra         

    tuidoc.FieldSetText "OfficeZip", plz 

    tuidoc.FieldSetText "OfficeCity", ort 

    tuidoc.FieldSetText "OfficePhoneNumber",phone 

    tuidoc.Refresh 

    tuidoc.Save 

    tuidoc.Close(True) 

    

    Messagebox "Finished creating the document!" 

    

    Goto ende 

notvalid:

    Messagebox" you enter a not valid Database",16,"Information" 

ende:

Subject: Problem with ComposeDocument

Hello,thanks a lot for the help.

The problem was fixed with

Dim fpath As String

fpath = session.GetEnvironmentString(“Directory”,True)

I use also

Dim vari As Variant

vari = sWorkspace.Prompt(13,“Get”,“Database”)

to get the Choose Database Popup

Now it is very comfortable.

Regards Lars

Subject: Problem with ComposeDocument

instead of using "…\notes\data"

try this

fpath = session.Environment(“Directory”) ’ check the exact syntax

fpath= fpath &"" & [user entry]

Subject: Problem with ComposeDocument

Hello lars,

I would recommend that you use the Prompt method from the NotesUIWorkspace class to get the server and path for the addressbook database, and then use the Notes back-end classes to “compose” your document (since you do not allow the user to do any editing to the document before you save and close it).

From Designer Help:

variant = notesUIWorkspace.Prompt( type%, title$, prompt$ [, default ] [, values ] )

Parameters

type%

Constant. Indicates the type of dialog box that you want to display. May be any of the following:

PROMPT_CHOOSEDATABASE (13)

Note The constant name PROMPT_CHOOSEDATABASE is not implemented in Release 6.0 but the literal value 13 can be used instead.

PROMPT_OK (1)

PROMPT_OKCANCELCOMBO (5)

PROMPT_OKCANCELEDIT (3)

PROMPT_OKCANCELEDITCOMBO (6)

PROMPT_OKCANCELLIST (4)

PROMPT_OKCANCELLISTMULT (7)

PROMPT_PASSWORD (10)

PROMPT_YESNO (2)

PROMPT_YESNOCANCEL (11)

And then instead of:

Set tuidoc = tworkspace.ComposeDocument( “”, "…\notes\data"&dirfn, “Person”,False )

'etc…

do:

Set tdoc = dbchk.CreateDocument

tdoc.ReplaceItemValue “Form”, “Person”

tdoc.ReplaceItemValue “LastName”, kunde

'etc…

tdoc.ComputeWithForm True, False

tdoc.Save True, False