Solved

Problem with Autonumbering & Autosave

Posted on 2003-10-23
6
262 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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 Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to connect (using VBA) to a IBM Notes webmail server 3 246
Migration Lotus to Exchange 2016 4 190
LotusScript: Merge Data to Word File 22 104
DNS error assumed 8 71
I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

830 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