IBM Support

How to programmatically edit the database property "Disable background agents for this database" with LotusScript

Technote (FAQ)


Question

How can you programmatically edit the database property "Disable background agents for this database" for more than one database?

Answer

You can leverage C API functions from the nnotes.dll through LotusScript. Below is an example of how edit a database property that is not normally editable through LotusScript.

The code below is a sample script, provided to illustrate one way to approach this issue. It is to be used as is and at your own risk. In order for this example to perform as intended, the script must be laid out exactly as indicated below. IBM Support cannot customize this script for specific environments or applications.

1. Create a new LotusScript agent.

2. Set the agent properties trigger to be "On event" with "Action menu selection" and the Target to "None".

3. Add the following to the LotusScript agent's Declarations section.


Const APIModule = "NNOTES" ' Windows/32 only
Const REPLFLG_NO_CHRONOS = &H0800
Public ThisDB As NotesDatabase
Public session As NotesSession
Type ReplicaInfo
ID(1) As Long
Flags As Integer
CutoffDays As Integer
CutoffDate(1) As Long
End Type

Declare Function NSFDbOpen Lib APIModule Alias "NSFDbOpen"_

(Byval P As String, H As Long) As Integer
Declare Function NSFDbClose Lib APIModule Alias "NSFDbClose"_

(Byval H As Long) As Integer
Declare Function OSPathNetConstruct Lib APIModule Alias_ "OSPathNetConstruct" (Byval Z As Long, Byval S As String,_

Byval F As String, Byval P As String) As Integer
Declare Function NSFDbReplicaInfoGet Lib APIModule Alias_ "NSFDbReplicaInfoGet" (Byval H As Long, R As ReplicaInfo) As Integer
Declare Function NSFDbReplicaInfoSet Lib APIModule Alias_ "NSFDbReplicaInfoSet" (Byval H As Long, R As ReplicaInfo) As Integer

4. Add the following to the LotusScript agent's Initialize section.


Sub Initialize
On Error Goto Errorhandling
Dim targetDB As NotesDatabase
Dim hDB As Long
Dim R As ReplicaInfo
Set session = New NotesSession

Set targetDB =_

session.GetDatabase("<ServerName>","<PathToDatabase>",False)
p$ = String(1024, " ")
OSPathNetConstruct 0, targetDB.Server, targetDB.FilePath, p$
NSFDbOpen p$, hDB
NSFDbReplicaInfoGet hDB, R
If (Not R.Flags And REPLFLG_NO_CHRONOS) = 0 Then
R.Flags = R.Flags And (Not(REPLFLG_NO_CHRONOS))
Messagebox "Agents Disabled ---> Enabling: " & R.Flags
Else
R.Flags = R.Flags Or REPLFLG_NO_CHRONOS
Messagebox "Agents not Disabled ---> Disabling: " & R.Flags
End If
NSFDbReplicaInfoSet hDB, R
NSFDbClose hDB
Exit Sub

SingleExit:
Exit Sub
Errorhandling:
Print Now , Str$(Err) , Error$ , Str$(Erl)
Exit Sub
End Sub

5. Replace <ServerName> in the Initialize portion of the agent with the proper server name. Review the NotesSession class method GetDatabase for proper syntax.

6. Replace <PathToDatabase> in the Initialize portion of the agent with the proper path to the database. Review the NotesSession class method GetDatabase for proper syntax.

Document information

More support for: IBM Domino Designer
LotusScript

Software version: 8.5, 9.0

Operating system(s): Windows

Software edition: Edition Independent

Reference #: 1380020

Modified date: 13 February 2012


Translate this page: