How To Set a Field in Another Database

I have been searching and searching, it just dawned on me to simply ask.

I’d like to create a button that will set a field in another database based on the “From” field in my database.

AKA: I got an e-mail from someone (scripted) that sends me a button. If I press that button (to approve their request) it will lookup their name (since they sent me the msg) and automatically set a field in a different database. Actually, it should technically clear (make null) the value in the other database.

I picked some code apart that I found elsewhere, but I’m missing the mark somewhere so I don’t know if this helps explain what I want to do or only muddy’s up the water more…

Sub Click(Source As Button)

Dim workspace As New NotesUIWorkspace

Dim uidoc As NotesUIDocument    

Dim fullName As String

Dim nameOnly As String

Dim db As NotesDatabase

Dim view As NotesView

Dim doc As NotesDocument

’ first, lets get the person’s name in the format we like

Set uidoc = workspace.CurrentDocument    

fullName = uidoc.FieldGetText( "From" )

nameOnly = Strleftback (fullName, "/")

’ now use that name as they key for the lookup

Set db = New NotesDatabase( "HubServer", "names.nsf" )

Set view = db.GetView( "($MyView)" )

Set doc = view.GetDocumentByKey( nameOnly )

’ finally, lets set the fields on that user’s document to null

Call doc.FieldSetText ( "MyField", "" )

End Sub

Thank you so much.

Subject: How To Set a Field in Another Database

In the code posted, “doc” is a back-end object and can be set by going: doc.MyField = “”

You can also go: doc.ReplaceItemValue(“MyField”,“”)

Also make sure that column in the view you are looking up the document is sorted ascending - I think GetDocumentByKey will use the first sorted column in the view.