Question

Next Available number BPM for a module

  • 31 January 2024
  • 3 replies
  • 57 views

  • Participating Frequently
  • 9 replies

Can a BPM be set up to add a sequential number into a field as a new record is entered?

Example, looking to have a BPM enter the Ship ID field (next available) when a new ship via address is entered into Epicor.

If this can be done thru BPM, what would that look like in the BPM designer?

Thank you for any assistance you can provide.

Jason


3 replies

Userlevel 4

If you want to keep it simple, create a User Code to hold the next number to be assigned (regardless of customer) then use 2 method directives:

GetNew (Post Processing) to set the field initially to “Auto” then on Update (Pre-Processing) call a custom code widget if the ID = “Auto”, take the value in the user code and populate to the required field then increment the user code by 1

If you want to separate by customer then you will have to do a much more complex set of BPMs to set the field to “Auto” initially then go and check what is the max ship to for the customer, then add 1 to it and return to the screen

Userlevel 3

We did something like this to auto-increment our customer IDs.  We use the first three letters of the customer name, and then a sequential ID.  The BPM searches for customers starting with the first three letters, order by custID desc.  You get the top result of that, parse out the number, and then increment it.

Here’s an example of how it can be done in a UD Table in a BPM ( In Trans Data directive) you could create a numeric UD Column in any table and do something similar.

var tmpRow = ttUD36.FirstOrDefault(o=> o.RowMod == "A");
if (tmpRow !=null)
{

if (tmpRow.Key3 == "Header")
{
int iLastRow = 0;
int iNextID = 0;
      var UD36Rows = (from UD36Row in Db.UD36
              where UD36Row.Company == Session.CompanyID 
              orderby UD36Row.Number01 descending
              select UD36Row).FirstOrDefault();
              {
                 var UD36Row = UD36Rows;
                 if (UD36Rows != null)
                        {
                         iLastRow = System.Convert.ToInt32(UD36Rows.Number01);
                         iNextID = iLastRow + 1;
                        }

               }  
  tmpRow.Key1 = iNextID.ToString();
  tmpRow.Number01 = System.Convert.ToDecimal(iNextID);
 }

Reply