New part number Generation

Where and How do set up the ability to generate the next available part number in a series? for example I have P900, P901, P902, P903. Z900, Z901, Z902, Z903 these numbers are already created and released in part maintenance.

I would like to be able grab the next number in one or the other sequence when creating a new part number in the part maintenance. For example when I Enter the first 2 characters I would like to have the program suggest the next one that is available.

Is this at all possible?
This would be similar to a Serial number generator that I have seen in the Past.

Nathan Pliska

We do that with a BPM. Launch bpm form to select the series start ID. Set that to a variable and write it to a UD table. UD also holds a number field with our start number. As we set the part field (Selection + number) we update the table to increment the number by one.

I saw a function in the Insight Lab book that would do this.
It would work for Customers, Suppliers, Project, and Parts.

I was able to make it work for Project numbers

I wrote this function to auto-increment part revisions. Same basic concept as your problem, where you’ve got a prefix and an incremented suffix. It calculates the next increment on the fly. It’s also meant to intake a fair amount of garbage as input (we don’t control our customer’s revision scheme), which is why the first thing it does is check to see if someone has even input anything. BaseRev can be empty and the function will spit out “-/00” as an output. User is supposed to just enter the customer rev, but it will try to decipher their attempts to manually increment too.

It’s attached to a Part.Update pre-proc BPM.

Your details will differ since you’re dealing with the Part table and you don’t care about effective date and you’re not using a delimiter, but the gist should be the same.

string PartNum: Our Part#
string BaseRev: This will either be whatever existing rev the user is uplifting, or a brand new rev the user inputs when creating a rev.
string NewRew: incremented revision

string customerRev = "";
string strInternalRev = "";
int intInternalRev = -1;
bool result = false;

//Pulls Last Revision by EffectiveDate if no rev is provided.
if (BaseRev.Length == 0 || BaseRev == "(new)")
    var lastRev = Db.PartRev.Where(pr => pr.PartNum == PartNum &&
                                         pr.AltMethod == "")
                            .OrderByDescending(pr => pr.EffectiveDate)
                            .ThenByDescending(pr => pr.RevisionNum)
                            .Select(pr => pr.RevisionNum);
    if (lastRev.Count() > 0)
        BaseRev = lastRev.First();
        BaseRev = "-";

//Splits the baseRev into a customer and PLN (internal) revs delimited by a slash.
if (BaseRev.LastIndexOf('/') == BaseRev.Length -3 &&
      char.IsDigit(BaseRev[BaseRev.Length -2]) &&
      char.IsDigit(BaseRev[BaseRev.Length -1]))
    customerRev = BaseRev.Substring(0, BaseRev.LastIndexOf('/'));
    strInternalRev = strInternalRev = BaseRev.Substring(BaseRev.LastIndexOf("/") + 1);
    result = int.TryParse(strInternalRev, out intInternalRev);
    result = true;
    customerRev = BaseRev;
//CustomerRev = customerRev; //For Testing
//InternalRev = strInternalRev; //For Testing
//Gets latest revision corresponding to the customer rev. If found, it updates PLN rev so that the system increments from the last rev.

var rev = Db.PartRev.Where(pr => pr.PartNum == PartNum &&
                                  pr.RevisionNum.StartsWith(customerRev + "/") &&
                                  pr.AltMethod == "")
                     .OrderByDescending(pr => pr.RevisionNum)
           .Select(pr => pr.RevisionNum)

if (rev != null)
    int intRev;
    string strRev = rev.Substring(rev.LastIndexOf("/") + 1);
    int.TryParse(strRev, out intRev);

    if (intRev > intInternalRev)
        intInternalRev = intRev;
//Increments internal rev and appends it to customer rev to produce new rev.
if (result)
    intInternalRev += 1;
    if (intInternalRev < 100)
        string newInternalRev = "00" + intInternalRev.ToString();
        NewRev = customerRev +
                 "/" +
                 newInternalRev.Substring(newInternalRev.Length - 2);
    else //It's unlikely that we'd see 100 internal revs on one CustRev, but...
    { throw new ArgumentOutOfRangeException("Next Internal Revision"); }
1 Like

Do you have a link to this lab book?

I don’t off hand,
I would think that Epicor has this in the Insights Lab book this week.