Prevent double entries

Prevent users from submitting a form twice.

A Computed <a href...> defines to open document or when is does not exists to create a new document.

When new doc is created and link has not been refreshed, the user could create a double entry.

I ran into situation where only one comment is allowed per field on a form.

An webqueryload agent checks if the document already exists and if so, it fills a field in the new document with the reference to the existing (new) form.

The Onload event of that form checks if the reference exists and if so, it changes the contents to the existing form.

This way you can prevent a user from submitting a new form twice.

Be careful, the page header must contain expire info.

This way you prevent that a double entry is made ( Although a webquerysave agent should doublecheck the save also)

Main Form
'HTML Header
"<script type='text/javascript'>"+@NewLine+
"function openwindow(site)"+@NewLine+

'Computed Href


"<a href='Javascript:{openwindow("+@Char(34)+"/" +@ReplaceSubstring(@Subset(@DbName;-1);"\";"/")+"/2dd262338b8f9919c1256ac500360c84/"+@DbLookup("";"";"C1";@Text(@DocumentUniqueID)+Fnm;2)+"?OpenDocument"+@Char(34)+")}'><IMG SRC='/icons/vwicn005' Border=0></a><br>";

@If(@IsDocBeingEdited = 1;"<a href='Javascript:{openwindow("+@Char(34)+"/" +@ReplaceSubstring(@Subset(@DbName;-1);"\";"/")+"/frmComment?OpenForm&ParentUNID="+@Text(@DocumentUniqueID)+ "&" +Fnm+@Char(34)+")}'><IMG SRC='/icons/vwdrafts.gif' Border=0></A>";" ") )

Comment/New form ( response )

'Prevent that browser uses cached form
HTML Head Content:
"<meta http-equiv='expires' content='Tue, 04 Dec 1993 
21:29:02 GMT'>"

@Command([ToolsRunMacro]; "QSWebCommentOpen")


var f = document.forms[0];

if (typeof f != "undefined")
 if ( f.Exists.value=="99") {

Agent used 
	This agent checks during load if a response form 
        for the specific field already exists.
        Since Notes Ignores a print comments, a value is set 
        on the form itself then the load event acts on this 
        value. You cannot use hide section stuff, cause the 
        HTML is already there.
	Dim currentDoc As CurrentWebDocument
	Dim db As NotesDatabase
	Dim viewValidation As NotesView
	Dim ValidationCollection As NotesDocumentCollection
	Dim WdocPath As Variant
	Dim docValidation As NotesDocument	
	Dim RespID,NRespID As String
	Set currentDoc = New CurrentWebDocument("")
	WdocPath  = currentdoc.doc.getitemvalue("zzDBPath")	
	Set db=currentdoc.doc.Parentdatabase
	dbserver = db.server
	If Dbserver = ""         Then 
		dbserver = "LocalHost" 
		DbServer = Mid(dbserver,Instr(dbserver,"=")+1)
		DbServer = Left(dbserver,Instr(dbserver,"/")-1)
	End If
	RespId = currentdoc.doc.query_string(0)
	RespId = Mid(RespId,Instr(RespID,"=")+1)
	NRespId = Left(RespId,Instr(RespID,"&")-1)
	NRespId = NRespID+Mid(RespId,Instr(RespID,"&")+1)
	Set viewValidation=db.GetView("C1")
	Set ValidationCollection = viewValidation.GetAllDocumentsByKey(NRespID  ,False) 
	If ValidationCollection.Count <> 0 Then
		Set docValidation=ValidationCollection.Getfirstdocument
		currentdoc.doc.Exists= "99"
		currentdoc.doc.OrgLink =  "http://" +dbserver + "/"+WdocPath(0)+"/"+Cstr(viewvalidation.UniversalID)+"/" +Cstr(docvalidation.UniversalID)
		currentdoc.doc.Exists= "00"
	End If
End Sub

Dig Deeper on Lotus Notes Domino Administration Tools

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...