Solved

Problem with Autonumbering & Autosave

Posted on 2003-10-23
6
253 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
HP DP 7.03 and lotus collaboration suite 9 3 151
Lotus Notes - Broken Links report 5 202
Username format for Domino LDAP 3 76
Domino Lotus Notes Client 4 67
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…
For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

919 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

22 Experts available now in Live!

Get 1:1 Help Now