Solved

Problem with Autonumbering & Autosave

Posted on 2003-10-23
6
263 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
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.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Suggested Courses

710 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