Adding user id to messagebox

I’ve pulled a recommended script from Lotus Support to assist with reducing the number of replication/save conflicts. I modified it by adding a Messagebox to the code to let the users know what is going on. I’m still new to scripting, but thought it would be cool to have the messagebox display who has the current document open. Does anyone have any suggestions on how to make this work? I’m not sure what the script command is to pull the ID.

I tried some variations, but kept receiving errors. Here is the code in it’s current fashion:

NOTE: My Unamea(1) string was an attempt to pull the information. It currently not being used.

Sub Queryopen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant, Continue As Variant)

Dim session As New notessession

Dim db As notesdatabase

Dim item As notesitem

Dim array(1) As String

Dim Unamea(1) As String

Set db=session.currentdatabase



If source.isnewdoc=False Then

	Set doc=source.document

	

	If doc.hasitem("Field1") Then

		Set item=doc.getfirstitem("field1")

		array(0)=item.values(0)

		If array(0)="Locked" Then

			Messagebox "This document is currently being edited.  Please try back later.",0,"Document In-Use"		

			continue=False

			Delete doc

		Else

			continue=True

			array(0)="Locked"

			item.values=array(0)

			docsaved=doc.save(False, False)

			If Not docsaved Then

				continue=False

				Delete doc

			End If

		End If

	End If

End If

End Sub

Thanks in advance for any feedback received!

Subject: Adding user id to messagebox

there is a catch 22 in your situation. The conflict occured because the document was saved. So when a document is opened there is really nothing locking the document.

I think you want to know if anyone is editing the document. That way no other person would modify the document. In this case document locking could help when a person bring a document into edit mode.

Do you follow?

HTH – Cheers – feel free to email if you more specifics.

Subject: Sure. Pretty simple really.

If source.isnewdoc=False Then		Set doc=source.document

	f1val = doc.Field1(0)

	If f1val <> "" Then

		Messagebox f1val, 0,"Document In-Use"		

		continue=False

		Delete doc

	Else

		continue=True

		uname = doc.ParentDatabase.Parent.CommonUserName

		doc.Field1 = "This document is currently being edited by: " + uname + ".  Please try back later."

		docsaved=doc.save(False, False)

		If Not docsaved Then

			continue=False

			Delete doc

		End If

	End If

End If

Subject: RE: Sure. Pretty simple really.

That worked great! I didn’t think about incorporating the message into one of my fields. Excellent learning lesson.