Many times we need unique running serial numbers. This is useful to generate Order numbers, Invoice numbers, Customer numbers etc. Lets implement this using MOND ESB in just 2 lines of code. Login to MOND ESB and create a new service. For this service, you do not need a source document type or a target document type. To generate any unique number, we need a pattern. MOND provides comprehensive support to generate unique numbers using different patterns including

  • Fixed text
  • Month, Year, Date, Time etc
  • Unique Serial Number, optionally padded with zero's, to get a fixed length
  • Increasing Serial Number starting from a particular number
  • Decreasing Serial Number starting from a particular number, etc.

In the MOND service, click the Input Output button and enter 'quoteNumber' as a String output variable. Close this tab and then click 'Add at same level' and choose Operator 'Variable --> Variable String'. Enter '$quoteNoPattern' as the variable name and [HM-QUOTE]-[%UniqueNumber-5] as Initial Value. This will generate numbers using the fixed block HM-QUOTE and a unique 5 digit number. Next, click 'Add at the same level' and choose Operator 'Util --> NumberGenerator'. In Object Name, enter SalesOrderNumber, or InvoiceNumber, or a unique identifier that represents the category for this number pattern. This way, you can have a different set of numbers for another category(object). In the number pattern dropdown, choose the previously saved variable'$quoteNoPattern' that holds the pattern based on which the number will be generated. Next enter '10000' as the starting number and choose the variable$quoteNumber in the Set Field dropdown. This will generate a unique number and save the output in this variable.

Click Simulate to run this service. You will see log entries similar to these

06:54:37.498:Executing Map:generateQuotationNumber- 1.00

06:54:37.498:Stored '[HM-QUOTE]-[%UniqueNumber-5]' in $quoteNoPattern

06:54:37.500:Stored 'HM-QUOTE-10000' in $quoteNumber

Click simulate again. You will see log entries similar to these

06:55:20.52:ExecutingMap:generateQuotationNumber - 1.00

06:55:20.52:Stored'[HM-QUOTE]-[%UniqueNumber-5]' in $quoteNoPattern

06:55:20.54:Stored'HM-QUOTE-10001' in $quoteNumber.

In less than 5 minutes we created a unique running serial number. You can invoke this service from BPM, WebService, REST API, other MOND Services etc..

Other Posts That Might Interest You.

Your Message to mondCloud
Optional Information That Helps Us Process Your Request Faster