Lotusscript and Replace Design using Mapped or UNC drive mapping (Rod Whiteley)

Hello

Has anyone encountered problems using the C API script to replace(refresh) design on a database that resides on a server from a client machine.

I am tying to replace design on a server database from a remote client, i retrieve the databases filepath using a mapped drive then pass it to the api call. The api cannot seem to find the database (Hdb returns as 0).

XXXXXXXXXXXXXX Call to the api XXXXXXXXXXXXXXXX

Sub Click(Source As Button)

Dim workspace As New notesuiworkspace

Dim session As New notesSession

Dim uidoc As NotesUIDocument



Dim Db As NotesDatabase

Set Db = session.CurrentDatabase

Set uidoc = workspace.currentdocument



Dim serverdir As String



serverdir = uidoc.fieldgettext("ServerDir") & "\" & db.filepath



Call ReplaceDesign(db.server, "Assets Template", "",serverdir)

End Sub

XXXXXXXXXXXXXXXX API Code XXXXXXXXXXXXXXXXXXXXX

Option Public

Const wAPIModule = “NNOTES” ’ Windows

Const NSF_INFO_SIZE = 128

Const INFOPARSE_DESIGN = 3

Const NOTE_ID_ICON = &HFFFF0010

Declare Private Function DesignRefresh Lib wAPIModule Alias “DesignRefresh” _

( Byval S As String, Byval hDB As Long, Byval F As Long, Byval zA As Long, Byval zM As Long) As Integer

Declare Private Function OSPathNetConstruct Lib wAPIModule Alias “OSPathNetConstruct” _

( Byval zP As Long, Byval S As String, Byval F As String, Byval N As String) As Integer

Declare Private Function NSFDbInfoGet Lib wAPIModule Alias “NSFDbInfoGet” _

( Byval hDB As Long, Byval D As String) As Integer

Declare Private Sub NSFDbInfoModify Lib wAPIModule Alias “NSFDbInfoModify” _

( Byval S As String, Byval W As Integer, Byval D As String)

Declare Private Function NSFDbInfoSet Lib wAPIModule Alias “NSFDbInfoSet” _

( Byval hDB As Long, Byval D As String) As Integer

Declare Private Function NSFDbOpen Lib wAPIModule Alias “NSFDbOpen” _

( Byval P As String, hDB As Long) As Integer

Declare Private Function NSFDbClose Lib wAPIModule Alias “NSFDbClose” _

( Byval hDB As Long) As Integer

Declare Private Function NSFItemSetText Lib wAPIModule Alias “NSFItemSetText” _

( Byval hNT As Long, Byval N As String, Byval D As String, Byval nD As Integer) As Integer

Declare Private Function NSFNoteOpen Lib wAPIModule Alias “NSFNoteOpen” _

( Byval hDB As Long, Byval NoteID As Long, Byval F As Integer, hNT As Long) As Integer

Declare Private Function NSFNoteClose Lib wAPIModule Alias “NSFNoteClose” _

( Byval hNT As Long) As Integer

Declare Private Function NSFNoteUpdate Lib wAPIModule Alias “NSFNoteUpdate” _

( Byval hNT As Long, Byval F As Integer) As Integer

Sub ReplaceDesign(templateserver$, templatename$, dbserver$, dbfilepath$)

dp$ = String(1024, " ")

OSPathNetConstruct 0, dbserver$, dbfilepath$, dp$



Dim hDB As Long

NSFDbOpen dp$, hDB

If hDB = 0 Then Exit Sub



d$ = Space(NSF_INFO_SIZE)

NSFDbInfoGet hDB, d$

NSFDbInfoModify d$, INFOPARSE_DESIGN, templatename$

NSFDbInfoSet hDB, d$



Dim hNT As Long

NSFNoteOpen hDB, NOTE_ID_ICON, 0, hNT

NSFItemSetText hNT, "$TITLE", d$, Instr(d$, Chr$(0))

NSFNoteUpdate hNT, 0

NSFNoteClose hNT



DesignRefresh templateserver$, hDB, 1, 0, 0



NSFDbClose hDB

End Sub

Subject: Lotusscript and Replace Design using Mapped or UNC drive mapping (Rod Whiteley)

I am also using this code withour any troubles. I just do not go through mapped drives. You also assume that the db on client machine has the same file path as on the server. What about if you try this:

Save also the name of the server where the db resides.

serverName = uidoc.fieldgettext(“ServerName”)

serverDir = uidoc.fieldgettext(“ServerDir”)

dbFilePath = serverDir + "" db.FileName

Call ReplaceDesign(db.server, “Assets Template”, serverName, dbFilePath)

I do not know if this works. But this way or not depending on the mapped drive and also in case the server name or file path is changing it is easily to correct.

Subject: Lotusscript and Replace Design using Mapped or UNC drive mapping (Rod Whiteley)

Do not use drive mapping to access a database on a Domino server. Use the Domino server to access the database, like: ReplaceDesign db.Server, “Assets Template”, db.Server, db.FilePath

Subject: RE: Lotusscript and Replace Design using Mapped or UNC drive mapping (Rod Whiteley)

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXWorked very well, thank you once again.

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Thanks for your quick responses, sorry i did reply earlier i was disconnected for the weekend, i will give your suggestions a try and post back my results.

Thanks

Peter Marcantonio