Auto Numbering - Customer ID

what :astonished: ?, do you mean when using Functions ?? if no, have you kindly got any example ?

i have just checked my revision 10.2.400.10 mate, no ttDate within this BO,

I am running 2021.2 in my screenshot and as you can see the tt tables are now gone

BTW - I tried doing the Customer ID code from this thread and also ran into the same issue.
Will need to learn how to resolve this issue.
Is this a C# problem or an Epicor Pseudo code?

When Epicor instituted the Kinetic universe it in effect tossed the capability to custom code using C# so the coding example provided earlier in this string won’t work in Kinetic. Either the code has to be reworked to fit with Kinetic (I think SQL code???) or you have to try to configure a custom solution utilizing the available constructs. If anyone has the Kinetic version of the C# custom code block and is willing to post it would make me and a few others quite happy.

When Epicor moved from Vantage 6 to Vantage 8, they made the decision to separate the business logic from the user interface. This was a very smart architectural move by Epicor. Separating out the concerns paved the way to move to SQL, REST, and now Kinetic. Eventually, people figured out that you could add adapters to the client and the horses got out of the barn. While these types of customizations solved some problems, they created others. The most notable, and loudest today, is that it makes upgrades more difficult. I’m sorry to say it but it’s a self-inflicted problem and now the bill is due for our technical debt.

Once we got to 10.2.500, Epicor functions became the correct way to call code blocks. For those who used functions, their move to Kinetic will be much easier than those of us who didn’t. Business logic belongs in Directives and Functions. UI concerns belong to Kinetic. Following these two rules will make our lives better in the long run.

2 Likes

I just replaced

foreach (var MyCust in ttCustomer.Where(MyCust => MyCust.Added()))

with

foreach (var MyCust in ds.Customer.Where(cust => cust.RowMod == "A"))

Should be a similar change for the ECO group.

1 Like

Ted

Did you ever find out where the sequencing baseline numbers were being stored? I built out a BPM to auto assign a customer number and it works just fine. The only problem is that I need to set the starting point because we’ve already been manually assigning numbers so once I can find how to set the initial value for auto sequencing I can turn on the BPM and I’m golden. So far nobody seems to know and I can’t find anything sleuthing around the data dictionary which seems to point to the location.

Company specific sequences are stored on Erp.CompanySequence. (There are other “sequence” tables but I think those predate CompanySequence, most should be here)

As the code says, the first time it calls GetNextSequence it will create the sequence using the ID passed, after that it is autoincremented, and I believe there is also a method to set the starting point after it is created. Something like SetSequenceValue I think.

Last I checked it is something like:
This gives you the next value:
NextValue.GetNextSequence(“CustID”)

This allows you to reset the next value
NextValue.SetSequenceCurrentValue(“CustID”, newNextValue)

Hi All, This solution has worked great for us the past two years, then we came upon 2022.1.3.

The logic of the methods works great however we took an extra step to set the Field Security of Customer.CustID to READ as default with the exception of a few user groups. This ensured that the “AutoAssign” was never overwritten by some of our basic users. With 2022.1.3, the “AutoAssign” has stopped being passed through to the Customer.Update method for users who are only able to READ that field which results in a Business Logic Error because there is no CustID. The “AutoAssign” still is being passed through for users who do not have that Field Security applied.

Any thoughts on how to resolve?

You set that field as Read Only so the field can’t be changed… Even when you do it via a BPM it still registers as a change. You cannot set the field as Read Only if you expect the user to be able to “change it” (even in a BPM).

So this must have been a bug that was finally fixed in this version? It had been working up until this update

I just did this in 2022.1 and wanted to provide the updated code to make it work in the version.

/*Either GET next customer number, or SET next customer number*/
/*if the customerID = "AutoAssign" just retrieve the next number
if the customerID = "AutoSet" set the new next value to the number found in the customer name.
*/
foreach (var MyCust in ds.Customer.Where(MyCust => MyCust.Added()))
{
var nv = new Ice.Lib.NextValue(Db);
string NextSequenceCode = "NextCustomer"; //change this to the value you want to retrieve
NextValueReset = 0; //prevents later message from showing
switch (MyCust.CustID)
{
case "AutoAssign":
//the following line will create a customer ID that starts with C with zero filled 6 digit number
MyCust.CustID = string.Format("C{0:00000}",nv.GetNextSequence(NextSequenceCode));
NextValueReset = 0; //prevents later message from showing
break;
case "AutoSet":
/*Here we can reset the next customer*/
// first we have to do call the getnextsequence,
// just in case this is the first time it is being called so that it creates the sequence
int Junk = nv.GetNextSequence(NextSequenceCode);
//now that we are sure it exists, we will set the next sequence value
NextValueReset = Int32.Parse("0" + MyCust.Name);
if (NextValueReset != 0) Ice.Lib.NextValue.SetSequenceCurrentValue(this.Db,NextSequenceCode,NextValueReset);
MyCust.CustID = "";
MyCust.Name = "";
break;
}
}
1 Like

Packaged up into a function:
(Just the next sequence for a key)
https://www.epiusers.help/t/lets-share-useful-functions-sharing-is-caring/100371/23

1 Like

Hi Tim,
i have done this in Engineering Workbench to Create an auto sequence ECO Group ID, if you still want it please let me know.

Hi Tim,
Thank you so much for this!!
I was able to implement this for a customer of mine and I like the latest iteration using the ICE built in function.
I implemented this in Kinetic 11.2.300.5 and had to change the code a bit. The prefix tt is no longer used and instead ds. prefix is used. So it’s now ds.Customer rather than ttCustomer.
Here is the working code for 11.2.300.5, though, I’m not sure when this change occurred.

/Either GET next customer number, or SET next customer number/
/*if the customerID = “AutoAssign” just retrieve the next number
if the customerID = “AutoSet” set the new next value to the number found in the customer name.
*/

foreach (var MyCust in ds.Customer.Where(MyCust => MyCust.Added()))
{

 var nv = new NextValue(Db);
 string NextSequenceCode = "NewCustomer"; //change this to the value you want to retrieve
 NextValueReset = 0; //prevents later message from showing
 switch (MyCust.CustID)
{
   case "AutoAssign":
   //the following line will create a customer ID that starts with C with zero filled 6 digit number
   MyCust.CustID = string.Format("{0:000000}",nv.GetNextSequence(NextSequenceCode));
   NextValueReset = 0; //prevents later message from showing
   break;
   case "AutoSet":
   /*Here we can reset the next customer*/
   // first we have to do call the getnextsequence,
   // just in case this is the first time it is being called so that it creates the sequence
   int Junk = nv.GetNextSequence(NextSequenceCode);
   //now that we are sure it exists, we will set the next sequence value
   NextValueReset = Int32.Parse("0" + MyCust.Name);
   if (NextValueReset != 0) NextValue.SetSequenceCurrentValue(this.Db,NextSequenceCode, NextValueReset);
   MyCust.CustID = "";
   MyCust.Name = "";
   break;
}

}

Hey Chris,
I used this solution but the code is just returning blank