?
Solved

Generating a sequential reference # for form submittals

Posted on 2003-03-19
4
Medium Priority
?
146 Views
Last Modified: 2013-12-24
Hi,

This is my dilema.  I need to be able to generate a sequential reference # for every form that is submitted through my site to my email and also to the person submitting the email.  They both need to be the same number.  I cannot use the CreateUUID() or the Random Numbers.  I need the reference # to be something along the lines starting at 2003001 (2003 designating the year and the 001 would consecutively increase into it reaches 500).  Any help would be greatly appreciated. Please be as specific as possible.  thanks.
0
Comment
Question by:hotnixon2000
[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
4 Comments
 
LVL 5

Expert Comment

by:JimV_ATL
ID: 8169485
<cfset timestamp = DateFormat(now(),"yyyymmdd") & TimeFormat(now(),"HHmmss")>

The above will create a number in the format 20030319154101.  I find this to be very helpful.  Perhaps it would work for you.
0
 
LVL 8

Accepted Solution

by:
TallerMike earned 200 total points
ID: 8169515
For it to be a truely sequential non-repeating number... you'll need to store this value in a DB somewhere. Then you'll need to query the next ID from the DB everytime you want a new one. If you're storing the form submissions in the DB, simply add a column to the DB that will house the ID. Then when you want a new ID, you'll need to do the following:

<cftransaction isolation="SERIALIZEABLE">
  <cfquery name="getNextID">
    SELECT MAX(ID)+1 AS nextID
    FROM TableName
  </cfquery>
  <cfset nextID = getNextID.nextID>
</cftransaction>

Alternatively, you could have a table where you simply house your sequential IDs, like so:

<cftransaction isolation="SERIALIZEABLE">
  <cfquery name="getNextID">
    SELECT MAX(ID)+1 AS nextID
    FROM IDTable
  </cfquery>
  <cfquery name="getNextID">
    UPDATE IDTable
    SET ID = ID + 1
  </cfquery>
  <cfset nextID = getNextID.nextID>
</cftransaction>

************************************************************************************************
************************************************************************************************

Another risky solutiuon is to use an application variable. like so:

<cfloop type="Application">
  <cfparm name="Application.mySeq" default="2003001">
  <cfset nextID = Application.mySeq>
  <cfset Application.mySeq = Application.mySeq + 1>
</cflock>

The problem with this is that when the server is rebooted, you loose this value.
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 10940752
No comment has been added lately, so it's time to clean up this question.
I will leave the following recommendation in the Cleanup topic area:

Accept TallerMike

Please leave any comments here within the next four days.

mrichmon
EE Cleanup Volunteer
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month7 days, 20 hours left to enroll

765 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