Home > Domino Tips > Developer > Domino > Prevent double entries
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

DOMINO

Prevent double entries


Folkert Sikkermqan
11.07.2001
Rating: -2.33- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


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

Problem:
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.

Solution:
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)



Code

*****************
Main Form
*****************
'HTML Header
"<script type='text/javascript'>"+@NewLine+
"function openwindow(site)"+@NewLine+
"{"+@NewLine+
"window.open(site,'my_new_window',"+
"'toolbar=no,location=no,directories=no,"+
"status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=460,height=340')"+@NewLine+
"}"+@NewLine+
"</script>"+@NewLine

'Computed Href
Fnm:="MyComment";
@If(!@IsNewDoc;

@If(!@IsError(@DbLookup("";"";"C1";@Text(@DocumentUniqueID)
Fnm;2));

"<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'>"


WebQueryOpen:
@Command([ToolsRunMacro]; "QSWebCommentOpen")


Onload:

var f = document.forms[0];


if (typeof f != "undefined")
{
 if ( f.Exists.value=="99") {
location=f.OrgLink.value+"?Opendocument";
	}
}




*******************
Agent used 
******************
%REM
	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.
%ENDREM
	
	
	
	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" 
	Else
		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)
	Else
		currentdoc.doc.Exists= "00"
	End If
End Sub

Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Domino
Mimic Lotus Notes Domino application functionality on the Web
A single form to view and edit any Lotus Notes document
DECS and DCR external data access considerations
How to create non-scrolling Lotus Domino view headers on the Web
Disabling the 'Submit' button on a form
An easier way to update a rich text field
Results from Default Notes Search have # of responses in brackets
Lotus Notes/Domino veteran offers comprehensive list of app dev tools
Notes to XML. . .and back again
Creating thumbnail images using LS2J in LotusScript

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Domino & Lotus Notes Security Solutions: Authentication, Antispam, Encryption and Antivirus
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts