# Set the next number in Ice.Lib.NextValue library

**URL:** <https://www.epiusers.help/t/set-the-next-number-in-ice-lib-nextvalue-library/122279>\
**Category:** Kinetic ERP\
**Created:** [January 12, 2025, 4:34pm UTC](https://www.epiusers.help/t/set-the-next-number-in-ice-lib-nextvalue-library/122279 "2025-01-12T16:34:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jgee](https://www.epiusers.help/user_avatar/www.epiusers.help/jgee/32/71125_2.png) [@jgee](https://www.epiusers.help/u/jgee)\
**Post date:** [January 12, 2025, 4:34pm UTC](https://www.epiusers.help/t/set-the-next-number-in-ice-lib-nextvalue-library/122279/1 "2025-01-12T16:34:26Z")

</div>

Is there a way to manually set the starting value of a record in the Ice.Lib.NextValue library?

We are importing a couple of thousand customers each which will be assigned a number from 000001 to 002000.

So I would like any customers manually entered after this to take 0002001.

I have seen some suggestions that we can run an SQL script but we are a cloud customer and I don’t believe we can run SQL commands on the database.

Any help would be great.

---

<div class="post-metadata">

**Author:** ![klincecum](https://www.epiusers.help/user_avatar/www.epiusers.help/klincecum/32/100137_2.png) [@klincecum](https://www.epiusers.help/u/klincecum)\
**Post date:** [January 12, 2025, 4:42pm UTC](https://www.epiusers.help/t/set-the-next-number-in-ice-lib-nextvalue-library/122279/2 "2025-01-12T16:42:40Z")

</div>

[https://www.epiusers.help/t/lets-share-useful-functions-sharing-is-caring/100371/23?u=klincecum](https://www.epiusers.help/t/lets-share-useful-functions-sharing-is-caring/100371/23)

More info in the above thread.

```cs
/*
  Function Packaging: Kevin Lincecum
  Credit goes to Tim Shoemaker and Jose Gomez.
  See this thread for much more information: https://www.epiusers.help/t/auto-numbering-customer-id/43884/10
*/

//ref: Bring in Ice.Lib.NextValue

//These sequences are GLOBAL (All Companies)

//No empty keys
if(String.IsNullOrEmpty(sequenceKey) == true) return;
if(String.IsNullOrWhiteSpace(sequenceKey) == true) return;

//Careful here..
using (ErpContext dbContext = Ice.Services.ContextFactory.CreateContext<ErpContext>()) //Erp Context
{
    Ice.Lib.NextValue.SetSequenceCurrentValue( dbContext, sequenceKey, ( newValue >= 0 ? newValue : 0 ) );
};

```
