Set the next number in Ice.Lib.NextValue library

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.

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

More info in the above thread.

/*
  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 ) );
};
5 Likes