Solved

Problem with Autonumbering & Autosave

Posted on 2003-10-23
6
264 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 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

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…
You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

634 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