Problem with session.CommonuserName

Hello, We recently upgraded our Notes/Domino environment from R5 to R7 since doing so, I encountered this issue with one of my databases.

I have the following code in the Terminate Event of the “Author” field to capture the field editor’s name, date & time. The field stop working for users that have R7 client.

Any feedback on this would be greatly appreciated.

Sub Terminate

Dim workspace As New NotesUIWorkspace

Dim session As New NotesSession

Dim uidoc As NotesUIDocument

Set uidoc = workspace.CurrentDocument

Author = uidoc.FieldGetText (“Author”)

RevApproval_a = uidoc.FieldGetText (“RevApproval”)

If Author = “” Then

If RevApproval_a <> “” Then

Author = "Completed by " & session.CommonUserName & " on " & Format(Now(), “Long Date”)

Call uidoc.FieldSetText (“Author”, Author)

Call uidoc.save

End If

End If

End Sub

Thanks in advane for your help!

Regards

-tb

Subject: problem with session.CommonuserName

You might be better off moving this code to the ‘QuerySave’ event of the form (you would need to remove the ‘Call uidoc.Save’ code).

Subject: RE: problem with session.CommonuserName

Thanks, Alex! When I placed the code in the ‘QuerySave’ event, I’m get ‘Variant doesn’t contain an object’ error and the validators name doesn’t append in the field. Any other suggestion?

Thanks Again!

tb

Subject: RE: problem with session.CommonuserName

Try this code in the QuerySave event of the form:

Dim Session As New NotesSession

Dim Doc As NotesDocument

Set Doc = Source.Document

Author = Doc.Author(0)

RevApproval_a = Doc.RevApproval(0)

If Author = "" Then

	If RevApproval_a <> "" Then			

		Author = "Completed by " & Session.CommonUserName & " on " & Format(Now, "Long Date")

		Call Doc.ReplaceItemValue("Author", Author)

	End If

End If

Subject: RE: problem with session.CommonuserName

Thanks, Alex! I placed your code in the QuerySave section and the field now shows the right user name. Since this is a workflow database, I have other three approval sections with the below code. The code executes when users click on action buttons to approve/deny a request.

How would I be able to incorporate the below code in the QuerySave event?

When supervisors approve a request, the request would be routed to a Manager. The manager section has two fields (MgrApproval & MgrAuthor). MgrApproval has a drop-down list of “Approved” & “Denied”. Inside the ‘MgrAuthor’ Terminate event, i have the below code to capture the Manager’s name when he/she approve/deny a request…

Sub Terminate

Dim workspace As New NotesUIWorkspace

Dim session As New NotesSession

Dim uidoc As NotesUIDocument

Set uidoc = workspace.CurrentDocument



MgrAuthor = uidoc.FieldGetText("MgrAuthor")

MgrApproval_a = uidoc.FieldGetText ("MgrApproval")

If MgrAuthor = "" Then     

	If MgrApproval_a <> "" Then

		

		MgrAuthor = "Completed by " & session.CommonUserName & " on " & Format(Now(), "Long Date") 

		Call uidoc.FieldSetText("MgrAuthor", MgrAuthor)

		Call uidoc.save

	End If

End If

End Sub

Director section have the below code…

Sub Terminate

Dim workspace As New NotesUIWorkspace

Dim session As New NotesSession

Dim uidoc As NotesUIDocument

Set uidoc = workspace.CurrentDocument



DirectorAuthor = uidoc.FieldGetText("DirectorAuthor")

DirectorApproval_a = uidoc.FieldGetText ("DirectorApproval")

If DirectorAuthor = "" Then     

	If DirectorApproval_a <> "" Then

		

		DirectorAuthor = "Completed by " & session.CommonUserName & " on " & Format(Now(), "Long Date") 

		Call uidoc.FieldSetText("DirectorAuthor", DirectorAuthor)

		Call uidoc.save

	End If

End If

End Sub

Thanks in advance for your help!

Subject: RE: problem with session.CommonuserName

The logic in the other sections is the same as that for the sample code I gave you. Shouldn’t be hard to use the example I gave and add more code and simply the replace the Author and RevApprover with the field names for your other sections.

Subject: RE: problem with session.CommonuserName

Thanks a lot, Alex! I did that and everything works fine now. I appreciate your patience!

tb