Auto Numbering - Customer ID

Cris_conn’s code

I resolved my issue, a ran a getData()

Bahahah I completely missed that!

I have tried your latest suggested method to auto-assign almost any ID. This is great, thank you. I am having an issue though when the user clicks on “Save” but forgot to fill a required field. I believe that “AutoAssign” case and GetNextSequence method are triggered (preprocessing) before the popup error (example: customer TermsCode was not selected). The sequence is incremented as many times as there is an error while saving.

Anyone found a way to avoid this?

Steps to reproduce :

  1. AutoSet the next customer to 1000;
  2. Fill required fields except TermsCode;
  3. Save (an error will be displayed);
  4. Select a TermsCode;
  5. Save. The customer ID will be 1001 instead of 1000.

No real way to avoid this, and that’s generally ok in my opinion there is’nt any REAL reason why the numbers should be actually sequential
There is no great significance to 1001 1002 vs 1001 , 1012 they both accomplish the same thing.

The only way around it would be to assign the ID after all the logic runs which is not possible since the ID is a required field itself.

Unless you set it to some random unique string first, do the work, look for the next available then reset it since it can be changed after the fact. But generally, the sequence number was the protection used for manual supplier creation outside of systems. It seems to get pulled into automated systems even though security should take care of the same issue.

1 Like

My logic “tries” to assign at the last minute, but if there is a problem during the save, AND THEN the user aborts the add, it will “burn” a customer ID… as long as they fix the problem and resave, it should not have this problem because I don’t calculate the number until Save.

Correct me if I am wrong. The Preprocessing BPM on Customer Update which calls GetNextSequence(…) is executed before the required fields validation (Epicor BaseProcessing is it?). If the user fixes the problem and then tries to save again, GetNextSequence(…) method is called one more time and a customer ID will be “burned”.

Yes, it is called, but only if the current customerID = “AutoAssign”… once it is assigned, the word “AutoAssign” is replaced with the newly calculate customer ID, and will not happen a second time.

You are right. I just don’t understand why in practice, the sequence is being incremented anyway. I added a PublishInfoMessage to the custom code before the switch case, but it is only being displayed when there is no required field error.

InfoBoxes don’t show up if there is an error that’s just “the way it works” unfortunatelly.

Good to know! Then does it mean that MyCust.CustID is not being changed from “AutoAssign” to the next sequence when there is an error? When pressing save again, the “foreach” retrieves the var MyCust with ID = “AutoAssign”.

image

Correct if there is an error all changes are “aborted” and it resets back generally speaking.

@josecgomez

Hello Jose, I m pretty new to Epicor 10,
I saw your youtube video about Auto Sequence Customer Id, and was able to copy that idea and make to work on ShitoNum.

Is there a way to make that ShiptoNum sequence by customer.
e.g.
Customer A
ShitoNum 1
ShitoNum 2
ShitoNum 3

and if I want to Add a new Shipto for Customer B , it should again start from 001.

Thanks in advance.

Thanks for posting this helpful document, Tim. We’re just at the beginning of our implementation phase, and this topic just recently came up. I’ll follow-up if we have any questions. Hope you’re doing well! Tony Gardner (Epicor Alumni).

1 Like

can you help me to implement the functionality while duplicating the Project from the project entry

Where in the database are the sequence numbers stored when using Ice.Lib.NextValue or Erp.Internal.Lib.CompanySequence

Hi dgreenEA,

Did you manage to do the automating of ID using the name of the vendor? I wanted to do same. Are you able to share more with me?

I am relatively new to BPM’s.
I believe that I am really close on this one though.
Trying to set the ECO group with the next sequential number.

My code is following everything from the process and updates per other notes in this thread.
Setting initial table is not working.
I have tried ttECOGroup, ttEngWorkBench, ttResults.ECOGroup

The name - ‘ttEngWorkBench’ does not exist in the current context.

Here’s my actual code

/*Either GET next ECOGroupID number, or SET next ECOGroupID number*/
/*if the xxxID = "AutoAssign" just retrieve the next number
if the xxxID = "AutoSet" set the new next value to the number found in the customer name.
*/
foreach (var MyECOGroup in ttEngWorkBench.Where(MyECOGroup => MyECOGroup.Added()))
  {
  var nv = new NextValue(Db);
  string NextSequenceCode = "NextECOGroup"; //change this to the value you want to retrieve
  NextValueReset = 0; //prevents later message from showing
  
  switch (MyECOGroup.GroupID)
  {
  case "AutoAssign":
  //the following line will create a ECO ID that with zero filled 6 digit number
  MyECOGroup.GroupID = string.Format("{0:000000}",nv.GetNextSequence(NextSequenceCode));
  NextValueReset = 0; //prevents later message from showing
  break;

case "AutoSet":
  /*Here we can reset the next GroupID*/
  // 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" + MyECOGroup.Description);
  if (NextValueReset != 0) NextValue.SetSequenceCurrentValue(this.Db,NextSequenceCode, NextValueReset);
  MyECOGroup.GroupID = "";
  MyECOGroup.Description = "";
  break;
   }
}

Depending on your version I believe Epicor did away with the tt tables in method directives (starting in E11) and in your case is now something like ds.EngWorkBench