Solved

Problem with Autonumbering & Autosave

Posted on 2003-10-23
6
252 Views
Last Modified: 2013-12-18
Hi,
   I am using this formula in a number field named 'Why_Why_Number' to auto-increment a sequential serial number on my documents.

@If(@IsNewDoc;@Subset(@DbColumn( "" : "NoCache" ; "" : "" ; "(docnumber)" ; 1 );1)+1;Why_Why_Number)

 It looks up to a view (docnumber) and increments by 1.The issue is that if 2 people attempt to create documents at the same time, I get 2 documents with the same number.

Is there any way to force the document to save immediately (without disrupting the input validation code I have on the other hundred fields) such that the serial number would be locked in as soon as it was created?
0
Comment
Question by:simpsop
6 Comments
 
LVL 9

Expert Comment

by:Arunkumar
ID: 9608187
0
 
LVL 14

Expert Comment

by:p_partha
ID: 9608190
Put this in the queryopen of ur form...

      If isnewdoc Then
            Dim ws As New notesuiworkspace
            Dim uidoc As notesuidocument
            Dim session As New notessession
            Set db = session.currentdatabase
            Set uidoc = ws.currentdocument
            Set view = db.getview("docnumber")
            Set doc = view.getfirstdocument
            t  = Cint(doc.fieldname(0))
            t = t+ 1
            doc.fieldname = t
            Call doc.save(True,True)
            Call uidoc.fieldsettext("why_why_number",Cstr(t))
            
      End If

change the fieldname alone to ur field name

HTH
partha
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 9608574
Instead of creating the number during open (which may or may not be saved) can be replaced to do that on save event.

@If(@IsDocBeingSaved;@Subset(@DbColumn( "" : "NoCache" ; "" : "" ; "(docnumber)" ; 1 );1)+1;Why_Why_Number)

~Hemanth
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:simpsop
ID: 9608638
Hemanth,
   So I'd remove the formula from the   Why_Why_Number   field and leave it set as Number |  Editable (instead of Number|Computed when Composed) , then assign the field value from the (docnumber) view using the formula:

@If(@IsDocBeingSaved;@Subset(@DbColumn( "" : "NoCache" ; "" : "" ; "(docnumber)" ; 1 );1)+1;Why_Why_Number)

 in the     querysave    of the form ?

-Paul
0
 
LVL 24

Accepted Solution

by:
HemanthaKumar earned 250 total points
ID: 9608727
No, The formula will remain in the field itself. THis will trigger when the document is being saved, until then the value is not incremented. There is absolutely no change done to the form, except for the formula
0
 
LVL 15

Expert Comment

by:Bozzie4
ID: 9613655
If it's very important to you that numbering unique, and you replicate your database over several servers, you should consider using an agent, running scheduled on 1 server, to update the numbers.

Create the Why_why_number field with a default value of 0 (computed when composed).  Optionally , use a field NumberAssigned (text ,default "0") to be certain you only assign a number once.
Now create a view numberQueue, with Select why_why_number=0  (and numberassigned="0").  Sort them by date ascending.

The agent : runs scheduled on 1 specific server, all documents in view numberQueue.

field why_why_number := @Subset(@DbColumn( "" : "NoCache" ; "" : "" ; "(docnumber)" ; 1 );1)+1;
field numberAssigned := "1";


This will assign numbers in 1 place, so duplicate numbers will not occur.  You do risk save conflicts, so use 'Merge field' on the form properties.

cheers,

Tom
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now