Joeydog
90 pts. | Jun 26 2008 2:44PM GMT
Thanks,
I can get the user name ok, but I am having trouble extracting the names fields from the document. What methods work best in Postopen?
There are 3, say okName1, okNmae2, okName3. Can you help with this?
I tried :
Dim okNameA as As notesName
Set okNameA = New notesName(notesSession.okName1)
Set user = New notesName <a href="http://notesSession.Com" title="http://notesSession.(" target="_blank">notesSession.Com</a>monUserName)
If user = okNameA Then
Source.Editmode = True
Call source.save
Source.Editmode = False
End If
but I am getting a Type mismatch error. R5.01.13
Brooklynegg
2685 pts. | Jun 27 2008 3:12PM GMT
You have no reference to the document that has the field values.
Here’s some code I put together from help information and combined with your examples. I have not tested this at all, but it should be close, assuming your user value gets set correctly. These methods should be correct for PostOpen. In your example, I don’t understand why you would save the document as soon as you force it into edit mode. I am against forcing saves. If the user makes changes and wants to save them, they can. You should give them the ability to discard changes.
Dim session As NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim editorname As Variant
Set session = New NotesSession
Set db = session.CurrentDatabase
Set dc = db.UnprocessedDocuments
Set doc = dc.GetFirstDocument
do until doc is nothing
Set user = New notesName <a href="http://notesSession.Com" title="http://notesSession.(" target="_blank">notesSession.Com</a>monUserName)
editorname = doc.okName1
if user = editorname(0) then
‘the rest of your code
end if
set doc = dc.getnextdocument(doc)
loop
Joeydog
90 pts. | Jun 30 2008 5:29PM GMT
Sorry if I haven’t made my issue clear.
I don’t need to loop through all the documents. If the user’s commonname opening the document matches either okName1, okName2, okName3 names of that document being opened, then I need that document to refresh the values in the computed fields ( RouteTo1, RouteTo2) of that document. So, when the user looks at their document it shows the correct values in RouteTo1, RouteTo2. Currently I rely on the user, opening their document to put it in Edit Mode, click Save then F9 to refresh before they route it (a button Action). But they don’t always do this and the document is being routed incorrectly.
As I tried to explain in my first post the computed fields that needs to be refreshed when opened, get their values from a view that draws from a different form (Maintain Names for Routing) that could be changed any time from a different user, but within the same db. There is no choice for the user to make, the computed fields need to refresh so that the document can route properly. PostOpen will run before the user puts any of their own changes in. Then normal Save conditions will apply for them.
I basically just need the document to refresh when opened, but only if the current user is one of those 3 okName fields. The biggest problem is understanding what PostOpen can do because if I use Call source.Save or Call source.Refresh I get a Document Command not available message. If I put it in Editmode then save, it refreshes ok, but I need it back in Read mode which causes it to loop.
This code loops:
Sub Postopen(Source As Notesuidocument)
Dim db As NotesDatabase
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim NitemokName1 As NotesItem
Dim NitemokName2 As NotesItem
Dim NitemokName3As NotesItem
Dim session As New NotesSession
‘ Dim update As String <== is Global declared Initialized with a “” value
Set wksp = New NotesUIWorkspace
Set session = New NotesSession
Set db = session.CurrentDatabase
Set uidoc = workspace.CurrentDocument
Set doc = uidoc.Document
Set NitemokName1 = doc.GetFirstItem(”okName1″)
Set NitemokName2 = doc.GetFirstItem(”okName2″)
Set NitemokName3 = doc.GetFirstItem(”okName3″)
If update <> ” Change Done” And (NitemokName1.contains <a href="http://session.com" title="http://session.(" target="_blank">session.com</a>monusername) = True) _
Or (NitemokName2.contains <a href="http://session.com" title="http://session.(" target="_blank">session.com</a>monusername) = True) _
Or (NitemokName3.contains <a href="http://session.com" title="http://session.(" target="_blank">session.com</a>monusername) = True) Then
Source.Editmode = True
Call uidoc.Save
update = ” Change Done”
Source.Editmode = False
End If
End Sub
**Querymodechange checks a Status field, if Closed no edit allowed.
This is driving me crazy, I didn’t thnk this would take so long to resolve. Thanks for any help!
Joeydog
90 pts. | Jun 30 2008 5:34PM GMT
Hi Again
Just to clarify, I am now getting my user commonname to compare to these field values ok: okName1, okName2, okName3. It is the “how to refresh” without causing a loop now! If I leave out the Source.Editmode = False line, all my data is correct, but want it back to Read mode.
Thanks






