Design Refresh Agent

Our administrators disabled the nightly design task on all servers. I need to write an agent to refresh the design of a handful of databases. I need to do this on a database level as I do not have rights to create a server program document. Has anyone been able to create an agent to do this?

Thanks.

Subject: Design Refresh Agent

Heres some code i used a while back. As is but it should get you started

'Declarations

Declare Function W32_NSFDbOpen Lib “nnotes.dll” Alias “NSFDbOpen” ( Byval

dbName As String, hdb As Long ) As Integer

Declare Function W32_NSFDbClose Lib “nnotes.dll” Alias “NSFDbClose” ( Byval hdb

As Long ) As Integer

Declare Function W32_NSFDbInfoGet Lib “nnotes.dll” Alias “NSFDbInfoGet” ( Byval

hdb As Long, Byval dbInfo As String ) As Integer

Declare Sub W32_NSFDbInfoModify Lib “nnotes.dll” Alias “NSFDbInfoModify” (

Byval dbInfo As String, Byval what As Long, Byval newValue As String )

Declare Function W32_NSFDbInfoSet Lib “nnotes.dll” Alias “NSFDbInfoSet” ( Byval

hdb As Long, Byval dbInfo As String ) As Integer

Declare Function W32_DesignRefresh Lib “nnotes.dll” Alias “DesignRefresh” (

Byval sourceServer As String, Byval hDb As Long, Byval dwFlags As Long, Byval

null0 As Long, Byval null1 As Long) As Integer

dim ss as NotesSession

Sub ButtonClick

If designReplace( “”, “MyDb.nsf”, “TemplateName”, “TemplateServer” , True )

Then

Print “Sweet!”

End If

End Sub

Function designReplace( strTargetServer As String, strTargetFile As String,

strTemplateName As String, strSourceServer As String, refreshNow As Integer )

As Integer

'strTargetServer is the server where the database to get new desig resides

'strTargetFile is the database

'strSourceServer is the server where the design is refreshed from

'refreshNow = True, starts refresh right away, otherwise youll have to wait for

the server or do it manually.

designReplace = False

Dim Sdb As String

Dim Tdb As String

Dim hdb As Long

Dim strDbInfo As String * 255

Dim strDBtitle As String * 255

Dim strDBtemplate As String * 255

Dim rc As Integer

Dim Force As Integer

'*** Build the path for target databases.

If strTargetServer = “” Then

Tdb$ = strTargetFile

Else

Tdb$ = strTargetServer & “!!” & strTargetFile

End If

'*** Get the db info from target database

rc% = W32_NSFDbOpen( Tdb$, hdb& )

If rc% <> 0 Then

'Error opening target database

Exit Function

End If

rc% = W32_NSFDbInfoGet( hdb&, strDbInfo )

If rc% <> 0 Then

'Error retrieving database info

Exit Function

End If

Call W32_NSFDbInfoModify( strDbInfo, 3, strTemplateName )

rc% = W32_NSFDbInfoSet( hdb&, strDbInfo )

If rc% <> 0 Then

'Error setting new design info

Exit Function

End If

If refreshNow Then

'Initiate refresh immediately…

rc% = W32_DesignRefresh( strSourceServer, hdb&, 0, 0, 0 )

End If

rc% = W32_NSFDbClose( hdb& )

designReplace = True

End Function

Subject: RE: Design Refresh Agent

Thanks Mark. I’ll give that a try.