BPM to Update or Create Method Directive for JCSyst

WARNING… This is not for the faint of heart… but doing it with Business objects is better than directly updating it.
Warning 2 You can create your OWN counters using these business objects
Warning 3 Changing standard numbers that are normally system controlled may cause unpredictable results… The normal system “next” numbers may not take kindly to being reset to values where they might stomp on previously created values.
Disclaimers done…
There are Business Objects specifically defined to modify these values. There are TWO possible places that “Next” numbers are saved… one is Database specific, and one is COMPANY specific… i believe that Jobs are company specific.

Company Specific next values
//Add Reference:
Erp.Internal.Lib.Shared.dll
//Add Using:
Using Erp.Internal.Lib;
Using Ice.Common;
The command to reset any value is:

string KeyForNextNumber = "NextJobNumber";
int NewNext = 1234;
nv.SetCurrentCompanySequence(MyCust.Company,KeyForNextNumber,NewNext);

FYI, you can also “get the next value” with the following command:

int NextValue = nv.GetNextCompanySequence(MyCust.Company, KeyForNextNumber);

DATABASE Next Values
There are some counters that are database specific rather than company specific… to update and use those,
These need :
Include: Ice.Lib
Reference: Ice.Lib.NextValue

//this gets increments the next number and returns it:
var nv = new NextValue(Db);
NextCustomerID =  nv.GetNextSequence(“NextCustomer_c”);


//this will CREATE the new Next key value (if necessary) and then resets the next value to 1313
var nv = new NextValue(Db);
int Junk = nv.GetNextSequence(“NextCustomer_c”);
NextValue.SetSequenceCurrentValue(“NextCustomer_c”, 1313);


//This will GET the current value of the next value without incrementing it:
var nv = new NextValue(Db);
Int CurrentValue =  nv.GetSequenceCurrentValue(Inputs.NextValueKey_chr.Value);
6 Likes