Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7709109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:46:56+00:00 2026-06-01T00:46:56+00:00

I needs some tips on this one, since I couldn’t find anything on this,

  • 0

I needs some tips on this one, since I couldn’t find anything on this, though it’s probably pretty simple to do, but I can’t think of a way.
Ok, so I need a hidden field which will automatically compute so called id numbers for every document, the numbers must start from 00001 and forward and must never ever repeat. For instance i create a document with numberId = 00001 and another document which creates numberId = 00002, if I ever delete the first or second document, the third created document should have numberId = 00003. No matter how many documents get deleted, the next document created should get the latest numberId and add 1 to it.

I hope I was clear about what I need here. I need an advice or a tip on how would I achieve this.

Also, I can’t use @Unique.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T00:46:58+00:00Added an answer on June 1, 2026 at 12:46 am

    Here is the code that you will need based on some of the comments to the question.

    function simplegetSequentialNumber(){
        synchronized(applicationScope){
            var newSeqNum:Int = 0;
            if (applicationScope.containsKey("seqNumber")){
                newSeqNum = applicationScope.get("seqNumber") + 1;
                applicationScope.put("seqNumber",  newSeqNum);
                var seqView:NotesView = database.getView("vw_SequentialNumberStore");
                var seqNumberDoc:NotesDocument = seqView.getFirstDocument();
                seqNumberDoc.replaceItemValue("seqNumber",applicationScope.get("seqNumber"));
                seqNumberDoc.save(true,true);
            } else {
                var seqView:NotesView = database.getView("vw_SequentialNumberStore");
                try {
                    var seqNumberDoc:NotesDocument = seqView.getFirstDocument();
                    applicationScope.put("seqNumber",seqNumberDoc.getItemValueInteger("seqNumber") + 1);
                    seqNumberDoc.replaceItemValue("seqNumber",applicationScope.get("seqNumber"));
                    seqNumberDoc.save(true,true);
                    newSeqNum = applicationScope.get("seqNumber");
                } catch(e) {
                    var seqNumberDoc:NotesDocument = database.createDocument();
                    seqNumberDoc.replaceItemValue("Form","cPanel");
                    seqNumberDoc.replaceItemValue("seqNumber",1);
                    applicationScope.put("seqNumber", 1);
                    seqNumberDoc.save(true,true);
                    newSeqNum = 1;
                }
            }
        }
        var seqNNNN:String = ("0000" + newSeqNum.toString()).slice(-4);
        return seqNNNN;
    }
    

    As you can see it first gets the next sequential number in a synchronized block, adds one to it and then puts the number back into the applicationScope.

    Then it converts it to the string, adds the additional 4 zeros and then the right 4 characters from it. This returns a string and needs to be stored in a text field. You cannot store it in a number field because Notes will automatically drop the leading zeros from the value.

    You can test this function by adding it to a server side javascript library and then including it in a simple page that runs a repeat control to repeat a computed field that just calls the function. Here is my test page.

    <?xml version="1.0" encoding="UTF-8"?>
    <xp:view xmlns:xp="http://www.ibm.com/xsp/core">
        <xp:this.resources>
            <xp:script src="/seqNum.jss" clientSide="false" />
        </xp:this.resources>
        <xp:repeat id="repeat1" rows="30" value="#{javascript:30}">
            <xp:text escape="true" id="computedField1"
                value="#{javascript:simplegetSequentialNumber();}" />
            <xp:br id="br1" />
        </xp:repeat>
    </xp:view>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've searched around, and saw some tips, but still couldn't find the solution to
I really need some quick tips here. I've got this VBScript script which sends
The project I'm working on needs some simple audit logging for when a user
I'm slowly getting into the position where one of my Django sites needs some
I need some tips on how to work with assets in Symfony 2. For
I'm making a dictionary database in SQLite and need some tips. My SQL is
Hey all i am in need of some helpful tips/advice on how to go
cowboy coder needs some help from SO-veterans: I have a given application that uses
Our vendor needs some access to our test server, and thus we send them
My index.html page for my project needs some Ruby code so I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.