Disabling Submit in case Document has been submitted once

Hi,I m trying to restrict submission of a web document when the person has submitted once…I am calling this agent in the WebQueryOpen event…However the prob is that the Document is not being saved even if person has not submitted the document even once.

Kindly Help.

Dim session As New NotesSession

Dim db As NotesDatabase

Dim doc,vdoc As NotesDocument

Dim view As NotesView



Set db=session.CurrentDatabase

Set doc=session.DocumentContext

Set view=db.GetView("ALL DOCUMENTS")

Set vdoc=view.GetFirstDocument



While Not vdoc Is Nothing

	vdocnm=vdoc.empname(0)

	If doc.empname(0)=vdocnm Then

		Call doc.replaceitemvalue("errmsg","Error")

		Exit Sub

	Else

	Call doc.Save(True,True)

		End If

	Set vdoc=view.GetNextDocument(vdoc)

Wend

Subject: Disabling Submit in case Document has been submitted once…

Hi - there are a few ways to do this. It’s probably simpler to check whether the document has already been saved using the onSubmit event.I would create a computed for display field containing a lookup of all the docs in your view (to check the current document against). You can do this with @dbcolumn. You need to make this field visible to javascript (but hidden to the user) so you need to wrap the field in pass-thru html, i.e .

Then, on your onsubmit event, you can check whether a field on the current document (I would use the UNID) exists in the computed for display field. The syntax would be something like:

var f = document.forms[0];

UNID = f.UNID.value;

List = f.yourfield.value;

if (List.indexOf(UNID)>-1){

alert(“This document has already been submitted.”);

return false;

}

Alternatively, you could simply use @dbcolumn/@dblookup/@isnewdoc to show or hide the submit button in different circumstances.

Subject: RE: Disabling Submit in case Document has been submitted once…

Thanks Paul,I m sending a link to Open a new Form to some candidates,so they open a new document everytime they click on the link.i was wondering if i can prevent them from submitting the document using LotusScript/Formula…