Hi, I’m a Notes administrator and am working on automating a couple of things using Lotus Script (within Domino Designer)
For creating mailin databases our users complete a form with the name of the database and the database owners etc. In the preferences of the mailbox itself, I want the owner field to be populated with the mailbox name (which the user specifies in the form). Currently, the name that appears in this field is the name of the administrator who creates the database, so we then have to manually change it to the actual mailbox name.
I believe the field is called ‘Owner’ and is within ‘CalendarProfile’. However, I’m having problems accessing this field. Does anyone have any advice how to go about this?
In the form the requester completes, they enter the name of the mailin database in a text field… I want to take this text and replace the text currently in the CalendarProfile Owner field with it.
Here is the code I have attempted:
Dim session As New notessession
Dim db2 As notesdatabase
Dim doc3 As notesdocument
Dim namName As NotesName
Set db2 = session.getdatabase( SERVER_NAME_IN_HERE, filename) 'filename is the name of the mailin (string)
Set doc3 = db.getprofiledocument("CalendarProfile")
Set namName = doc3.getItemValue("Owner")(0) ' trying to access owner field and save contents as NotesName
'then trying to replace the string in the owner field with the string the requester specifies as the mailin name, but have been unable to get the text in the owner field.
I apologise if this is fairly straightforward. I’m not a developer!
create and agent in your domino directory and use this code. You must have a Person or Database document open in the UI.
Sub Initialize
Dim checkrole As Variant
checkrole = Evaluate( { @UserRoles } )
check% = False
Forall r In checkrole
If r = "[NetModifier]" Then
check% = True
End If
End Forall
If check% = False Then
Msgbox "You are not authorized to run this process.", 16, "Aborting ..."
Goto xit
End If
Dim ns As New NotesSession
Dim ws As New NotesUIWorkspace
Dim doc As NotesDocument
Dim uidoc As NotesUIDocument
Set uidoc = ws.CurrentDocument
If Not uidoc Is Nothing Then
Set doc = uidoc.Document
If doc.Type(0) = "Person" Or doc.Type(0) = "Database" Then
sn$ = uidoc.FieldGetText("MailServer")
fp$ = uidoc.FieldGetText("MailFile")
If sn$ = "" Or fp$ = "" Then
Msgbox "aborting, mail server or mail file field is blank"
Goto xit
End If
If Right$(fp$, 4) <> ".nsf" Then
fp$ = fp$ & ".nsf"
End If
' Do it here
Dim maildb As NotesDatabase
Set maildb = ns.GetDatabase(sn$, fp$)
If maildb.IsOpen Then
nam$ = ws.Prompt (PROMPT_OKCANCELLIST, "Select a name ...", "Which name would you like to use?", doc.FullName(0), doc.FullName)
If nam$ = "" Then
Msgbox "Action cancelled, you did not select a name from the list"
Goto xit
End If
Dim note As NotesDocument
Set note = maildb.GetProfileDocument( "CalendarProfile" )
If note Is Nothing Then
Msgbox "aborting, unable to get Calendar Profile"
Goto xit
End If
ask2:
ask2% = ws.Prompt( 2, "Confirm ...", "You are about to change the mail file owner in " & maildb.Title & " from " & note.Owner(0) & " to " & nam$ & ", continue?")
If ask2% <> 1 Then
Msgbox "Action Cancelled!"
Goto xit
Else
note.Owner = nam$
Call note.ComputeWithForm(True, False)
Call note.Save(True, False)
Msgbox "mail file owner has been successfully changed!"
End If
Else
Msgbox "aborting, could not open mail file"
Goto xit
End If
Else
Msgbox "aborting, process may only be run against Person and Mail-In Database documents"
Goto xit
End If
Else
Msgbox "aborting, selected document must be open to run this process"
Goto xit
End If