Hello,
I have been asked to set up autoassign on customer numbers for multiple companies within my Epicor database.
I have it set up for Company ‘ODD’ and it works fine.
I was hoping to just set the method directives to ‘Company Independent’ and have each company use their own autoassigned number.
My problem is, it looks like the below code uses a system wide counter (I may be mistaken).
When I try to autoassign in a different company ‘OVR’, it grabs the next number from company ‘ODD’.
I didn’t try to rest the number in ‘OVR’ because I didn’t want to mess up ‘ODD’ unless someone here tells me that the counters are independent from each other but just set the same accidentally.
Would someone on here please look at the below code and tell me if it is system wide or company specific for holding the counter?
If it is system, is there a way to make it company specific?
If not, is my best shot to just set it to ‘Company Dependent’ and recreate it on the other company? (If this is a system counter, it may not help doing that way).
Any and all help is truly appreciated!
/*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 ttCustomer.Where(MyCust => MyCust.Added()))
{
var nv = new 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":
int nextVal = nv.GetNextSequence(NextSequenceCode);
string testCustomer = "zzz";
do{
testCustomer = (from c in Db.Customer where c.Company == Session.CompanyID && c.CustID == nextVal.ToString() select c.CustID).FirstOrDefault();
if(testCustomer == null){
//the following line will create a customer ID that starts with C with zero filled 6 digit number
MyCust.CustID = string.Format("{0:00000}",nextVal);
}else{
nextVal = nv.GetNextSequence(NextSequenceCode);
}
}while(testCustomer != null);
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 sequenceint 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;
}
}