# How do I change the logic of Order number and Customer number?

**URL:** <https://forum.litium.com/t/how-do-i-change-the-logic-of-order-number-and-customer-number/50>\
**Category:** Questions\
**Tags:** accelerator, order\
**Created:** [May 4, 2018, 8:54am UTC](https://forum.litium.com/t/how-do-i-change-the-logic-of-order-number-and-customer-number/50 "2018-05-04T08:54:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cissi](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/cissi/32/18_2.png) [@Cissi](https://forum.litium.com/u/Cissi)\
**Post date:** [May 4, 2018, 8:54am UTC](https://forum.litium.com/t/how-do-i-change-the-logic-of-order-number-and-customer-number/50/1 "2018-05-04T08:54:56Z")

</div>

I want both of them to start at a specific number (ex 2 200 000).  
And if it’s possible I also want the numbers to be uneven.

Litium version: Accelerator MVC 5.5.1

---

<div class="post-metadata">

**Author:** ![patric.forsgard](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/patric.forsgard/32/10_2.png) [@patric.forsgard](https://forum.litium.com/u/patric.forsgard)\
**Post date:** [May 4, 2018, 9:36am UTC](https://forum.litium.com/t/how-do-i-change-the-logic-of-order-number-and-customer-number/50/2 "2018-05-04T09:36:40Z")

</div>

The readable numbers is generated in database and is from the below tables and sequences depend on Litium version. To update to use another range you simply update the value.

To make usage of other number pattern like uneven you need to manual set the readable number on the entities and also maintain the values by yourself.

**Litium 4 and 5**

- Readable order number is from database table `ECommerce_ReadableID`
- Readable delivery number is from database table `ECommerce_ReadableDeliveryID`
- Readable customer number (person and organization) is from database table `Relations_ReadableCustomerID`

**Litium 6 and 7**

- Readable order number is from database table `ECommerce_ReadableID`
- Readable delivery number is from database table `ECommerce_ReadableDeliveryID`
- Readable customer number (person and organization) is from the database sequence `Customers.CustomerId`.

You should also be aware of following stored procs that fetches these auto increment numbers.

- `ECommerce_GetReadableID`
- `ECommerce_GetReadableDeliveryID`

By changing the stored procs, you can supply any number, as long as they are unique.

---

<div class="post-metadata">

**Author:** ![anusha.ganegoda](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/anusha.ganegoda/32/58_2.png) [@anusha.ganegoda](https://forum.litium.com/u/anusha.ganegoda)\
**Post date:** [May 8, 2018, 7:33am UTC](https://forum.litium.com/t/how-do-i-change-the-logic-of-order-number-and-customer-number/50/5 "2018-05-08T07:33:45Z")

</div>

For customer number (if you are using Litium 5 or before) you can change the stored procedure `dbo.Relations_GetReadableCustomerID` (following code is only an example, examine the deployed version of this stored proc in your database).

```auto
-- Returns a unique string as the External Order ID 
ALTER PROC [dbo].[Relations_GetReadableCustomerID]
	@ReadableCustomerID nvarchar(100) OUTPUT
AS
BEGIN
	DECLARE @Prefix nvarchar(10)
	SET @Prefix = 'LSC'
	INSERT INTO dbo.Relations_ReadableCustomerID DEFAULT VALUES
	SELECT @ReadableCustomerID = @Prefix + CAST(IDENT_CURRENT('dbo.Relations_ReadableCustomerID') AS nvarchar(90))
	
	WHILE (SELECT COUNT(1) FROM dbo.Relations_Person WHERE CustomerNumber = @ReadableCustomerID) > 0 OR (SELECT COUNT(1) FROM dbo.Relations_Organization WHERE CustomerNumber = @ReadableCustomerID)> 0
	BEGIN
		INSERT INTO dbo.Relations_ReadableCustomerID DEFAULT VALUES
		SELECT @ReadableCustomerID = @Prefix + CAST(IDENT_CURRENT('dbo.Relations_ReadableCustomerID') AS nvarchar(90))
	END	
	RETURN
END
```

---

<div class="post-metadata">

**Author:** ![marten](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/marten/32/11_2.png) [@marten](https://forum.litium.com/u/marten)\
**Post date:** [May 8, 2018, 8:33am UTC](https://forum.litium.com/t/how-do-i-change-the-logic-of-order-number-and-customer-number/50/7 "2018-05-08T08:33:25Z")

</div>

Remember that any change you do to existing procedures probably need to be re-applied again after every future upgrade.

---

<div class="post-metadata">

**Author:** ![control](https://avatars.discourse-cdn.com/v4/letter/c/838e76/32.png) [@control](https://forum.litium.com/u/control)\
**Post date:** [March 10, 2021, 9:59am UTC](https://forum.litium.com/t/how-do-i-change-the-logic-of-order-number-and-customer-number/50/8 "2021-03-10T09:59:57Z")

</div>

Is it possible to pass the prefix from .net code ??

One more dobut :

- `ECommerce_GetReadableID`

this store proc where is this called from ?

---

<div class="post-metadata">

**Author:** ![NilsN](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/nilsn/32/302_2.png) [@NilsN](https://forum.litium.com/u/NilsN)\
**Post date:** [March 11, 2021, 8:19am UTC](https://forum.litium.com/t/how-do-i-change-the-logic-of-order-number-and-customer-number/50/9 "2021-03-11T08:19:18Z")

</div>

It’s not possible to pass a prefix from code. In later versions you can set what this [should be in Web.config](https://docs.litium.com/documentation/get-started/web_config#Change%20prefix%20for%20order%20and%20delivery%20numbers)

The stored procedure is called internally when creating the order to get the next available order number.

---

<div class="post-metadata">

**Author:** ![Spotonkastebo](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/spotonkastebo/32/717_2.png) [@Spotonkastebo](https://forum.litium.com/u/Spotonkastebo)\
**Post date:** [March 12, 2021, 1:35pm UTC](https://forum.litium.com/t/how-do-i-change-the-logic-of-order-number-and-customer-number/50/10 "2021-03-12T13:35:26Z")

</div>

Perhaps it is simpler to just change the external order number after order is created.  
Maybe one can add the the the state machine in for exempel exit-action for initstate och entry action for waitingforconfirmation if there arent a better place.
