The code below works great except it changes the status of document that i do the search for and not the current doc that is opened. The code is at the very bottom. Thanks ahead of time
Sub Click(Source As Button)
Dim ws As New NotesUIWorkspace
Dim response As String
Dim db As NotesDatabase
Dim searchDB As NotesDatabase
Dim searchDBName As String
Dim searchView As notesView
Dim searchDoc As NotesDocument
Dim session As New NotesSession
Dim proDoc As notesdocument
Dim doc As NotesDocument
Set db = session.CurrentDatabase
Dim view As NotesView
Dim selection As String
Dim user1 As Variant
Set doc=db.CreateDocument()
user1 = doc.curAuthor
'user1= source1.FieldGetText( "curAuthor" )
key = user1
Set view = db.GetView("(Profile Document)")
Set doc = view.GetDocumentByKey (key )
Dim item As NotesItem
Set item = doc.GetFirstItem( "phone_st" )
If ( item Is Nothing ) Then
Print "no phone item found"
Else
Dim phone As Variant
phone = doc.GetItemValue( "phone_st" )
Call doc.ReplaceItemValue( "phone_st", "On Phone" )
Call doc.Save( False, True )
Call ws.ViewRefresh
End If
'***********************************************************************************
Call ws.EditDocument( True )
Set doc = db.CreateDocument
Dim Change As Variant
Change = doc.GetItemValue( "Status" )
Call doc.ReplaceItemValue( "Status", "In Progess" )
Call doc.Save( False, True )
'*****************************************
The bottom shows that you are creating a new document called ‘doc’. Which overrides the previous doc being set. So, in the bottom section, just call it newdoc, or something else.
I changed the bottom to newdoc and having the same problem.Sub Click(Source As Button)
Dim ws As New NotesUIWorkspace
Dim response As String
Dim db As NotesDatabase
Dim searchDB As NotesDatabase
Dim searchDBName As String
Dim searchView As notesView
Dim searchDoc As NotesDocument
Dim session As New NotesSession
Dim proDoc As notesdocument
Dim doc As NotesDocument
Set db = session.CurrentDatabase
Dim view As NotesView
Dim selection As String
Dim user1 As Variant
Set doc=db.CreateDocument()
user1 = doc.curAuthor
'user1= source1.FieldGetText( "curAuthor" )
key = user1
Set view = db.GetView("(Profile Document)")
Set doc = view.GetDocumentByKey (key )
Dim item As NotesItem
Set item = doc.GetFirstItem( "phone_st" )
If ( item Is Nothing ) Then
Print "no phone item found"
Else
Dim phone As Variant
phone = doc.GetItemValue( "phone_st" )
Call doc.ReplaceItemValue( "phone_st", "On Phone" )
Call doc.Save( False, True )
Call ws.ViewRefresh
End If
'***********************************************************************************
Dim newdoc As NotesDocument
Call ws.EditDocument( True )
Set newdoc = db.CreateDocument
Dim Change As Variant
Change = newdoc.GetItemValue( "Status" )
Call newdoc.ReplaceItemValue( "Status", "In Progess" )
Call newdoc.Save( False, True )
'*************************************************
If you want to update the Current Document, that is open in the UI, use the NotesUIWorkspace CurrentDocument Property to get the document, and update it. You will probably want to use the refresh method of the NotesUIDocument to refresh it on the screen.
Dim ws As New NotesUIWorkspace
Dim response As String
Dim db As NotesDatabase
Dim searchDB As NotesDatabase
Dim searchDBName As String
Dim searchView As notesView
Dim searchDoc As NotesDocument
Dim session As New NotesSession
Dim proDoc As notesdocument
Dim newdoc As NotesDocument
Set db = session.CurrentDatabase
Dim view As NotesView
Dim selection As String
'*******************************************************************************
Dim user1 As Variant
Set newdoc=db.CreateDocument()
user1 = newdoc.curAuthor
'user1= source1.FieldGetText( "curAuthor" )
key = user1
Set view = db.GetView("(Profile Document)")
Set newdoc = view.GetDocumentByKey (key )
Dim item As NotesItem
Set item = newdoc.GetFirstItem( "phone_st" )
If ( item Is Nothing ) Then
Print "no phone item found"
Else
Dim phone As Variant
phone = newdoc.GetItemValue( "phone_st" )
Call newdoc.ReplaceItemValue( "phone_st", "On Phone" )
Call newdoc.Save( False, True )
Call ws.ViewRefresh
End If
'***********************************************************************************
Dim doc As NotesDocument
Call ws.EditDocument( True )
Set doc = db.CreateDocument
Dim Change As Variant
Change = doc.GetItemValue( "Status" )
Call doc.ReplaceItemValue( "Status", "In Progess" )
Call doc.Save( False, True )
'**********************************************************************************