Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Need Order ID Number Creator

Guest
Aug 20, 2008 Aug 20, 2008
Employer wants an Order number starting with I and haveing 6-8 characters in. So for example first order would be I000601. Anyone have any ideas of scripts or items that would create this. Need to make sure that it doesn't duplicate. I know CreateUUID would be perfect for this but it is way too long. Suggestions.
471
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 20, 2008 Aug 20, 2008
PopcornCoder wrote:
> Employer wants an Order number starting with I and haveing 6-8 characters in.
> So for example first order would be I000601. Anyone have any ideas of scripts
> or items that would create this. Need to make sure that it doesn't duplicate.
> I know CreateUUID would be perfect for this but it is way too long.

> Suggestions.

That's fine, what are the rest of the business rules? I.E. are these
random numbers or sequential, etc.

Otherwise this is just basic logic and string manipulation probably
combined with a look up of existing recorded order numbers to ensure
uniqueness.

A super basic example.

<cfscript>
i = randRange(1,99999999);
invoiceNum = 'I' & replace(rJustify(i,6),' ','0','ALL');
writeOutput(invoiceNum);
</cfscript>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 20, 2008 Aug 20, 2008
Prefer sequential and starting at the I000601 number
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 24, 2008 Aug 24, 2008
LATEST
Building on Dan's last suggestion, using a small table with increment,
try the following it should work for you.

This method will also let you reset the number should that be necessary.

<cfquery name="rs_order_number" datasource="dsn">
SELECT order_number
FROM order_number
</cfquery>

<cfquery name="update_order_number" datasource="dsn">
UPDATE order_number
SET order_number = order_number + 1
</cfquery>

<cfset order_number = "I#NumberFormat(rs_order_number.order_number,00000000)#">

<cfoutput>#order_number#</cfoutput>

Leonard B
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 20, 2008 Aug 20, 2008
If you are using oracle, you could create a sequence starting at 601. Then you can pad it with zeros and prepend the letter I.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 20, 2008 Aug 20, 2008
Not using oracle but thanks for the idea.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 20, 2008 Aug 20, 2008
Try something similar with an application variable.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 20, 2008 Aug 20, 2008
quote:

Originally posted by: Dan Bracuk
Try something similar with an application variable,
or a small table that you select from and increment



Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources